我已经通过干净的网址上的多个线程,但我仍然对它感到困惑。我想在核心PHP网站中使用干净的URL策略。我改变了我的多个URL的.htaccess文件。但我下面的代码工作只为一个页面(一个网址)干净的网址在核心PHP
# Turn on the Rewrite Engine
RewriteEngine on
# Rewrite for buyleads.php
RewriteRule ^buyleads buyleads.php [NC,L]
## NC makes the rule non case sensitive
#L makes the last rule that this specific condition match
# Rewrite for search.php?u=xxx
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)$ search.php?cat=$1 [L]
# Rewrite for search.php?u=xxx&subcat=xxx
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)$ search.php?cat=$1&subcat=$2 [L]
# Rewrite for detail.php?u=xxx
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^detail/([a-z0-9]+)$ /detail.php?id=$1 [L]
问题1.上面的代码工作只为search.php中,如果我进入www.sitename.com/detail/29(detail.php代码)它的工作原理就像www.sitename/29(search.php)。我在它做了什么错误
问题2我也想知道是否真的有可能通过只有.htaccess文件来制作所有这样的网址?有没有什么办法可以在核心php中创建?
问题3最后,我想知道如何通过.htaccess自动重定向到清理url,就像在点击用户后点击CLick这个应该去www.sitename.com/34/50。
在此先感谢
原始URL /路径详细了解'.htaccess'和'RewriteCond'。我想你只需要在每个块中添加一个关于何时跳过重写小节的条件。目前所有请求都由第一个块满足,如'search.php'。提示:与URI匹配,显然可以有其他方式,但这就是我现在能想到的。 – Jigar
可以请你解释一下吗? – nehaJ