.htaccess 我想通过htaccess更改网址

uidvcgyl  于 2022-11-16  发布在  其他
关注(0)|答案(1)|浏览(127)

我想通过htaccess将URL从http://localhost/projectname/cab-details.php?v_name=variable更改为http://localhost/projectname/variable此处**变量是一个链接(slug)**现在我的htaccess代码是

Options +FollowSymlinks

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME}\.php -f

RewriteRule ^(.*)$ $1.php

RewriteRule ^$1/([a-zA-Z-0-9-]+) cab-details.php?v_name=$1
j2qf4p5b

j2qf4p5b1#

请使用显示示例尝试以下.htaccess规则文件请确保在测试URL之前清除浏览器缓存

RewriteEngine ON
RewriteBase /omm/
##External redirect rules here.
RewriteCond %{THE_REQUEST} \s/(omm/[^.]*)\.php\?v_name=(\S+)\s [NC]
RewriteRule ^  /%1/%2? [R=301,L]

##Internal redirect rules here.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^omm/([^/]*)/([^/]*)/?$  $1.php?v_name=$2 [QSA,NC,L]

相关问题