【发布时间】:2012-11-21 09:27:08
【问题描述】:
我有一个 URL 重写设置来创建漂亮的 URL
RewriteCond %{REQUEST_URI} !^\/*(index\.php|blog|admin\/assets|site\/assets|robots.txt|sitemap.xml|products.xml|favicon\.ico)
RewriteRule ^(.*)$ /index.php?rq=$1 [L,QSA]
当我使用/admin 访问管理区域时,URL 被重写为/admin/?rq=admin,因为我有一个名为“admin”的根级目录。这可能很简单,但我怎样才能编辑(或添加到)我的 .htaccess 规则,以便将 url 清楚地写为/admin/
更新:
澄清一下,我想使用 /index.php?rq=admin 访问 /admin 而不是调用 /admin/index.php
这是我的 apache 虚拟主机配置:
<VirtualHost *:80>
ServerAdmin alex
ServerName hub
ServerAlias hub
DocumentRoot /var/www/hub/
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/hub>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
【问题讨论】:
标签: .htaccess mod-rewrite rewrite