简体   繁体   English

Htaccess重写规则具有友好的URL

[英]Htaccess Rewrite Rule to have a Friendly URL

I'm using godaddy hosting and my domain is pointed to the directory named "abc" I created a directory "temp" under "abc" directory and placed an .htaccess file under "temp" directory. 我正在使用godaddy托管,并且我的域指向名为“ abc”的目录,我在“ abc”目录下创建了目录“ temp”,并在“ temp”目录下放置了一个.htaccess文件。

I want to rewrite url as follow 我想重写URL如下

http://www.mywebsite.com/temp/VARIABLE_VALUE/VARIABLE_FILENAME.php?id=12&c=usa

to

http://www.mywebsite.com/temp/VARIABLE_FILENAME.php?var=VARIABLE_VALUE&id=12&c=usa

my .htaccess file consists of the following code. 我的.htaccess文件由以下代码组成。

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^([^-]*)$ /temp/index.php?var=$1 [L]

But, it gives me 404 error. 但是,它给了我404错误。

You can use this rule in 您可以在

Options +FollowSymLinks
RewriteEngine On
RewriteBase /temp/

RewriteRule ^([^/]+)/([^.]+\.php)$ $2?var=$1 [L,QSA]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM