我无法为htaccess文件获取正确的代码以正确重写我的网址。
我正在尝试改写:
www.page.com/user/projects/index.php?project_id=1到
www.page.com/user/projects/1
这是我在.htaccess文件中的内容
RewriteEngine On
RewriteBase /
RewriteRule ^projects/([0-9]+)/?$ index.php?project_id=$1 [NC,L]
当我转到page.com/users/projects/1时出现404错误,显然重写不正常。一些帮助将不胜感激!
由于
答案 0 :(得分:2)
您可以在/user/projects/.htaccess
。
RewriteEngine On
RewriteBase /user/projects
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9]+)/?$ index.php?project_id=$1 [NC,L]
从根本上你可以做到。
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\ /+user/projects/index\.php\?project_id=([^&\ ])
RewriteRule ^ %1? [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^user/projects/([0-9]+)/?$ /user/projects/index.php?project_id=$1 [NC,L]