Friday, 15 April 2011

.htaccess - htaccess, Regex, Rewrite URL -



.htaccess - htaccess, Regex, Rewrite URL -

hmm have problem .htaccess, wanted rewrite this:

http://domain.com/a/thread-103518.html#103518

to this

http://domain.com/a/103518

in other words... want delete "thread-" , after "." /a/ must variable... there other forums /bla/ , /code/

do have clue me? give thanks you

my .htaccess right now:

rewritecond %{request_filename} !-d rewritecond %{request_filename}.php -f rewriterule ^(.*)$ $1.php

rewritecond %{the_request} ^[a-z]+\ /index.php rewriterule ^index.php/?(.*) /$1 [l,r=301]

add .htaccess file in document_root

rewriteengine on rewriterule ^([^/]+)/thread-(\d+) $1/$2? [dpi,l,r]

tested in apache 2.2 , 2.4 :)

this assumes mod_rewrite both installed and activated htaccess files. if not sure, check if mod_rewrite installed, @ list of installed modules in output of phpinfo(); default, mod_rewrite not enabled htaccess files. if managing own server, open httpd.conf , create sure webroot directory block contains 1 of these lines: allowoverride fileinfo or allowoverride all

regex .htaccess url rewrite

No comments:

Post a Comment