The URL in the browser would be:
https://css-tricks.com/index.php/teachers/a/
The actual page rendered by the server would be:
https://css-tricks.com/index.php?search=teachers&sort=a
RewriteEngine on
RewriteRule ^index/([^/]+)/([^/]+).php /page.php?search=$1&sort=$2 [NC]
I think you messed up a little, the URL in browser example wouldn’t match the Rewrite Rule. The URL in browser example would have to be “https://css-tricks.com/index/teachers/a/”
I tried playing with it myself, and this works:
https://css-tricks.com/examples/Rewrite/index.php/teachers/a/b/
And this doesn’t:
https://css-tricks.com/examples/Rewrite/index/teachers/a/b/
Oh, I think the only reason it works for me is because I I have rewrite rules that lets me take out the .php extension.
I like the idea of a clearer URL, but still I think keeping ‘index’ or ‘index.php’ as part of the URL has very little added value. I’d prefer something like https://css-tricks.com/teachers/a/ instead.
Its a clearer URL and improves SEO more importantly.
Slight problem. If you want to link to something deeper than the root of your website, it would be passed as an argument in index.php.
Instead, use a keyword like “search” to give yourself more latitude. The resulting https://css-tricks.com/search/teachers/a/ is SEO-friendly and you only limit yourself to avoiding a folder named “search”.
use it https://css-tricks.com/examples/Rewrite/index.php/teachers/a/b/
Nice one, thanks chris.
Its what I was finding for as it is very useful in php based website and seo friendly too.
The Reference URL is giving the full details. Thanks for providing it too.
Hey, Chris!
I’m struggelin and messing around these .htaccess, but I couldn’t write them as they work. I have mod_rewrite enabled, and I double checked that RewriteEngine is on at .htaccess file.
In example, I have one project, where, i have sections and categories, and link looks like this: http://localhost/eshop/index.php?section=fruits&category=apple
How I could rewrite this link to get it look like this: http://localhost/eshop/fruits/apple
And also I have similar situation inside WordPress.
I’ ve made theme, where I made a new engine for some kind of inside social network, but anyway.
For example, link looks like this: http://localhost/liepa6vsk/klases/?classroom_id=5&page=gallery
I would like to make it appear as http://localhost/liepa6vsk/klases/classroom_name/gallery
What I should write in .htaccess to do that, and still not crush previously written Rewrite rules for wordpress?
One last question: Does link will appear nice, when in link will be only http://localhost/liepa6vsk/klases/?classroom_id=5 (as http://localhost/liepa6vsk/klases/classroom_name/)
If you gonna solve my questions, you will be like God for me :)
@Robertr: the following code in your .htaccess file will fix the first problem:
RewriteEngine on #unless the rewrite engine is already declared
RewriteBase /eshop/ #if you dont have a rewrite base, it can cause issues with sub-directories.
RewriteRule ([^/]+)/([^/]+) index.php?section=$1&category=$2 [NC]
What if we want ?site={siteslug} to redirect to *.mysite.com
htaccess file works only on apache server, but i am currently using ASP that doesn’t run this file through IIS.. so any other ways to rewrite my URL??
You can use web.config file in Windows IIS 7 or higher.
Also refer below links
http://www.iis.net/download/URLRewrite
http://learn.iis.net/page.aspx/461/creating-rewrite-rules-for-the-url-rewrite-module/
You can also just use
$_SERVER["PATH_INFO"]
to get everything after/index.php/
.thanks everybody
can any one suggest, what should i do, if i want the usernames to be a part of url..
such as http://localhost/animeshkumar/
instead of http://localhost/profile.php?userID=1
where userID : 1 has the username : animeshkumar in the database..
You would have to have your php search for the username instead of the id.
http://localhost/animeshkumar/
How to remove the php extension on go daddy server?
OptionMultiviews On does not work for me..:(
“How to remove the php extension on go daddy server?”
Hi Amit Yadav,
It doesn’t matter who is the hosting provider.
It only matters whether your web host has installed Apache server or not.
Apache sever supports dynamic URL rewriting technique (ModURL Rewrite)
RewriteEngine on
RewriteRule ^index-([^/]+)-([^/]+).php /search.php?search=$teachers&sort=$ohio [NC]
Using this above code will rewrite the query string URL http://yoursite.com/search.php?search=$teachers&sort=$ohio into
http://yoursite.com/index-teachers-ohio.php
Hi,
any one help me in .htaccess?
http://gilltech.in/portfolio/ open the portfolio page in woirdpress.
but http://gilltech.in/portfolio/seowebin-free-seo-tool show 404 (page not found error), but i want to open same page http://gilltech.in/portfolio/ when this url is open.
thanks
RewriteRule ^([a-zA-Z0-9-/]+)/$ sample.php?pageid=$1
jquery file is not working with httaccess redirect any one please help me…
hi, how to create urls which display at google search results as below
css-tricks.com › Code Snippets › HTAccess
instead of
stackoverflow.com/questions/…/htaccess-seo-friendly-urls-for-all-subf
URL should look like http://localhost/test/url-2.html but content should come from http://localhost/test/url?p=2
please help.