htaccess problem 404 not found

喜夏-厌秋 提交于 2020-12-14 06:29:16

问题


I have rewrite URL like following

RewriteCond %{HTTP_HOST} ^subdomain\.mydomain\.example$
RewriteRule (.*) /subdomain/$1 [L]

RewriteRule ^a/(.*)/(.*)$ search.php?searchtext=$1&locationtext=$2 [NC]

And I want to call my page like

http://kolkata.mydomain.example/a/phptraining/Kolkata

But when page is opening this is saying 404 not found. I’m not understanding this error.


回答1:


With this rule set only the first rule is probably applied but not the second. Try the first rule without L flag and consider a possible subdomain within the request path:

RewriteCond %{HTTP_HOST} ^subdomain\.mydomain\.example$
RewriteRule .* /subdomain/$0
RewriteRule ^([^/]+/)?a/([^/]+)/([^/]+)$ $1search.php?searchtext=$2&locationtext=$3 [NC]


来源:https://stackoverflow.com/questions/3223063/htaccess-problem-404-not-found

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