I have a file called car-details.php it takes the variable id= with the cars registration details in order to populate the page.
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. Whenever I've tried to add a second forward slash the rewrite rule stops working. Any help?
full htaccess file below
# 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]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.