开发者

.htaccess code for url rewriting

开发者 https://www.devze.com 2023-04-03 13:40 出处:网络
I want to use url rewriting in my site as follow: When user try to access http://www.mysite.com/sectionname/

I want to use url rewriting in my site as follow: When user try to access

http://www.mysite.com/sectionname/

for processing it must go to file as

http://www.mysite.com/ha开发者_如何学Cndler.php?sect=sectionname

but in address bar user must see first url only.

I used following code but it's not working

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^([^/]+)$ sectionthumbs.php?sect=$1

but it's not working. Please tell me where I m wrong. Thanks in advance....


Something like this should work:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /handler.php?sect=$1 [L,QSA]


As @Repox said,

however I use something like this for all my past projects:

RewriteRule ^([^/\.]+)/$ index.php?module=$1 [L]

But that's because I use MVC

Another little trick, say that you had a variable passed into the query string, to make it look pretty /media/this_is_article you would use something like:

RewriteRule ^media/([^/\.]+)/?$ index.php?media=$1 [L]
0

精彩评论

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