我对 .htaccess 和 mod_rewrite 很陌生。我可以准备带有特定网址的 seo 友好网址。但是,我想制作一个为我统一一切的东西。
例如;
Original : http://www.domain.com/index.php?module=profile&id=1.
SEO : http://www.domain.com/profile/1
.htaccess Code: RewriteRule ^profile/(.*) ?module=profile&id=$1 [L]
如您所见,我必须在文件中指定profile
任何其他模块名称.htaccess
我想做的是;
Original : http://www.domain.com/?request=module/profile/id/1/other/any
SEO : http://www.domain.com/module/profile/id/1/other/any
然而 mod_rewrite 的相同逻辑并不适用。
RewriteRule ^(.*) ?request=$1 [L]
反正有这个问题吗?
我完整的.htaccess;
# Disable server signature
ServerSignature Off
####################################################################
# MOD REWRITE
####################################################################
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule (.*) /index.php?request=$1 [L]
</IfModule>
我可以毫无问题地使用它;
# Disable server signature
ServerSignature Off
####################################################################
# MOD REWRITE
####################################################################
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule ^/ index.php [L]
RewriteRule ^content/(.*) ?module=content&request=$1
</IfModule>
工作版
# Disable server signature
ServerSignature Off
####################################################################
# MOD REWRITE
####################################################################
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteBase /
RewriteRule (.*) index.php?request=$1 [L]
</IfModule>
但是我仍然需要至少指定一件事。
感谢您的帮助。