开发者

How can I rewrite this URL with Apache?

开发者 https://www.devze.com 2023-01-27 19:20 出处:网络
I want to be able to access sitenamehere.com/folder/index?a=something by visiting sitenamehere.com/folder/something in开发者_开发百科 my address bar.

I want to be able to access sitenamehere.com/folder/index?a=something by visiting sitenamehere.com/folder/something in开发者_开发百科 my address bar.

How can I do this?

I've looked into mod rewrite but I don't understand it.


mod_rewrite is an Apache (web server) extension not related to PHP. You'll want to create a file called .htaccess and include the following line:

RewriteEngine On
RewriteRule ^folder/(.*) /folder/index.php?a=$1

http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html


Your .htaccess or httpd.conf.

# Turn on URL rewriting
RewriteEngine On

# Installation directory
RewriteBase /

# Your rule
RewriteRule ^([^/]+)/([^/]+)/?$ $1/index?a=$2 [L]

This assumes you want where folder is to be mapped over to where folder is in your example. If you want to match the literal folder, just replace the first capturing group with it (and add it to the replacement).

0

精彩评论

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

关注公众号