【发布时间】:2016-12-13 11:50:43
【问题描述】:
我有一个名为 car-details.php 的文件,它使用带有汽车注册详细信息的变量 id= 来填充页面。
我目前可以让这个重写规则生效
RewriteRule ^car-for-sale/(.*) car-details.php?id=$1 [NC,L]
但我想要一个类似的网址
/GV09LBX/Ford-car-something-etc
但由于某种原因,我无法让网址的第二部分正常工作。我遵循了一些指南,以便在下面的 url 示例中添加第二部分
RewriteRule ^car-for-sale/(.*)/(.*) car-details.php?id=$1&something=$2 [NC,L]
car-details.php 文件甚至没有使用 something=$2,但我只想在 url 中包含汽车名称以用于 seo 目的。每当我尝试添加第二个正斜杠时,重写规则就会停止工作。有什么帮助吗?
完整的 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>
【问题讨论】:
标签: php apache .htaccess mod-rewrite seo