开发者

htaccess mod_rewrite directory to variable

开发者 https://www.devze.com 2023-03-20 07:11 出处:网络
I\'m having some trouble with mod_rewrite in my .htaccess file. I\'ve found numerous tutorials about how to do the reverse of what I\'m trying to accomplish.

I'm having some trouble with mod_rewrite in my .htaccess file.

I've found numerous tutorials about how to do the reverse of what I'm trying to accomplish.

Basically I need a solution to change directories to get variables.

So that this:

http://example.org/page-1

turns into开发者_StackOverflow社区

http://example.org/?link_id=page-1

I think I got a code that would do something almost to what I need, but I was getting redirect loops.


Here you go:

RewriteEngine On
RewriteRule ^page-([0-9]*)$ index.php?link_id=page-$1

Note: I'm not sure that index.php is your DirectoryIndex. If it's not, you should change it according to your index file.

0

精彩评论

暂无评论...
验证码 换一张
取 消