.htaccess - htaccess seo friendly urls for all subfolders -
i have script in index.php in folders
need create pretty url/seo friendly urls this: site.com/folder1/something.html
now have ugly urls this: site.com/folder1/index.php?category=something
this part index.php?category=something
same in subfolders, want alter more seo friendly something.html
once again: find index.php?category=1$
, replace 1$.html
not touch else, part of url
so when visit:
site.com/another-subfolder/and-one-more-folder-here/index.php?category=something
need see in address bar:
site.com/another-subfolder/and-one-more-folder-here/something.html
i hope it?
i tried folder1
in htaccess in root
rewriterule ^folder1/(.*).html$ folder1/index.php?category=$1 [l,r=301]
ok works, how can create work subfolders accross site this:
site.com/folder145/index.php?category=something site.com/subfolder/index.php?category=something site.com/another-subfolder/and-one-more-folder-here/index.php?category=something
there 1000s of subfolders different names manually making rewriterule each subfolder won't work
any help appreciated
first, need alter links generate index.php?category=
form category.html
form.
then in htaccess file in document root, add together these rules internally rewrite category.html
form index.php?category=
form:
rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.+?/)?([^/]+)\.html$ /$1index.php?category=$2 [l]
then, point links don't have command on (or ones generated using form) externally redirect direct access links in index.php?category=
form:
rewritecond %{the_request} ^(get|head)\ (/.*?)?/index\.php\?category=([^&\ ]+) rewriterule ^(.+?/)?index\.php$ /$1%3.html? [l,r=301]
this should match , every subdirectory.
.htaccess
No comments:
Post a Comment