如何修改我的子文件夹
How to modrewrite in my subfolder
我在服务器的子文件夹中有一个 PHP 脚本,它生成 url 如下:
http://example.com/subfolder//index.php?a=profile&u=username
相反,我想要一个 SEO 友好的 url,例如:
http://example.com/subfolder/profile/username.html
我在 Apache 上并且启用了 mod_rewrite,所以我编辑了我的子文件夹页面的 .htaccess
:
RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)\.html$ //index.php?a=&u= [L]
但是没有用。
这是我的完整 .htaccess
代码:
RewriteEngine on
RewriteCond %{request_filename} -f
RewriteRule ^(.*) [L]
RewriteRule ^(([^/]*)+)(/([^/]{0,32})(/.+)?)?$ index.php?a=&q= [L]
RewriteRule ^([^/]*)/([^/]*)\.html$ //index.php?a=&u= [L]
我的代码有什么问题?
在/subfolder/.htaccess
中使用此规则:
RewriteEngine on
RewriteBase /subfolder/
RewriteRule ^([^/]+)/([^/]+)\.html$ index.php?a=&u= [L,QSA,NC]
我在服务器的子文件夹中有一个 PHP 脚本,它生成 url 如下:
http://example.com/subfolder//index.php?a=profile&u=username
相反,我想要一个 SEO 友好的 url,例如:
http://example.com/subfolder/profile/username.html
我在 Apache 上并且启用了 mod_rewrite,所以我编辑了我的子文件夹页面的 .htaccess
:
RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)\.html$ //index.php?a=&u= [L]
但是没有用。
这是我的完整 .htaccess
代码:
RewriteEngine on
RewriteCond %{request_filename} -f
RewriteRule ^(.*) [L]
RewriteRule ^(([^/]*)+)(/([^/]{0,32})(/.+)?)?$ index.php?a=&q= [L]
RewriteRule ^([^/]*)/([^/]*)\.html$ //index.php?a=&u= [L]
我的代码有什么问题?
在/subfolder/.htaccess
中使用此规则:
RewriteEngine on
RewriteBase /subfolder/
RewriteRule ^([^/]+)/([^/]+)\.html$ index.php?a=&u= [L,QSA,NC]