.htaccess mod rewrite and MAMP

六月ゝ 毕业季﹏ 提交于 2019-12-11 05:18:21

问题


having issues with what i think is linked to the mod rewrite in mamp.

The rewrite works fine on the live server, but im working locally with MAMP and getting issues.

The problem is linked to this:

I rewrite the following URL:

http://localhost/BuildSanctuary-Dev/viewbuild/64/three-fiddy-z/1

That should rewrite as:

http://localhost/BuildSanctuary-Dev/viewbuild.php?id=64&title=three-fiddy-z&page=1

The issue is that i get a 404 for page not found.

The requested URL /viewbuild.php was not found on this server.

Which it clearly is... but if i visit just /viewbuild.php it works fine.

The rewrite in the .htaccess is:

RewriteRule ^viewbuild/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/?$ /viewbuild.php?id=$1&title=$2&page=$3 [L,QSA]

Any ideas? I have done the research and everything in the apache conf is showing as Allowing All...

Thanks.


回答1:


Your rewriterule redirects to /viewbuild.php and not /BuildSanctuary-Dev/viewbuild.php:

RewriteRule ^viewbuild/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/?$ /BuildSanctuary-Dev/viewbuild.php?id=$1&title=$2&page=$3 [L,QSA]

A mabye better variant would be to put the .htaccess into the /BuildSanctuary-Dev/ folder and use a relative path as redirect:

RewriteBase /BuildSanctuary-Dev
RewriteRule ^viewbuild/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/?$ viewbuild.php?id=$1&title=$2&page=$3 [L,QSA]


来源:https://stackoverflow.com/questions/25435621/htaccess-mod-rewrite-and-mamp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!