[英]get htaccess to ignore part of a Url
I have a file called car-details.php it takes the variable id= with the cars registration details in order to populate the page. 我有一个名为car-details.php的文件,它使用带有汽车注册详细信息的变量id =来填充页面。
I can currently get this rewrite rule working 我目前可以使该重写规则正常工作
RewriteRule ^car-for-sale/(.*) car-details.php?id=$1 [NC,L]
But I would like to have a url like 但我想有一个网址像
/GV09LBX/Ford-car-something-etc
but for some reason I just can't get the second part of the url to work. 但由于某些原因,我无法使网址的第二部分起作用。 I followed some guides in order to add a second part to the url example below
我遵循了一些指南,以便在下面的网址示例中添加第二部分
RewriteRule ^car-for-sale/(.*)/(.*) car-details.php?id=$1&something=$2 [NC,L]
Where something=$2 isn't even used by the car-details.php file but I would just like to have the car name in the url for seo purposes. car-details.php文件甚至没有使用something = $ 2,但我只想在seo中将汽车名称包含在url中。 Whenever I've tried to add a second forward slash the rewrite rule stops working.
每当我尝试添加第二个正斜杠时,重写规则都会停止工作。 Any help?
有什么帮助吗?
full htaccess file below 完整的htaccess文件如下
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^car-for-sale/(.*)/(.*) car-details.php?id=$1&something=$2 [NC,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
# Wordfence WAF
<IfModule LiteSpeed>
php_value auto_prepend_file '/home/shipley/public_html/wordfence-waf.php'
</IfModule>
<Files ".user.ini">
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
<IfModule !mod_authz_core.c>
Order deny,allow
Deny from all
</IfModule>
</Files>
You must use anchor in your patterns: 您必须在模式中使用锚点:
RewriteRule ^car-for-sale/([^/]+)/([^/]+)/?$ car-details.php?id=$1&something=$2 [NC,L,QSA]
RewriteRule ^car-for-sale/([^/]+)/?$ car-details.php?id=$1 [NC,L,QSA]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.