I'm trying to learn how to rewrite URL's within htaccess files.
If anyone can give me some good links that would be brilliant.
I'm trying to aim to rewrite this:
http://www.domainname.co.uk/news/newsSingle.php?ID=9
to this:
http://www.domainname.co.uk/news/category-name/post-name.php
I have the category-name & post-name within the database for each matching ID.
Any help would be great thanks!
you can take a look at
9lessons.info
Media Temple
Stack Overflow .htaccess
Hope these help you find the answer.
Related
How to create an SEO friendly URL like example.com/pages/my-first-page/followers here I want how to create a structure in if(isset($_GET['followers'])){...} and htaccess file.
My link working fine till example.com/pages/my-first-page/ but now I want to add followers section.
I hope i explain well what I expecting. Thanks for your help
Rule you've suggested is this:
RewriteRule ^pages/([\w-]+)/followers/?$ page.php?pages=$1&followers=1 [QSA,NC,L]
This is pretty good rule and there is no reason why it should not work. Make sure this rule is placed before page rule which is your first rule in .htaccess
Hi there I have been looking through some of the posted answers on how to do this and I am coming up a bit lost. Some of the posts I have read are as follows:
Rewrite search page query URL with htaccess
What does RewriteBase do and how to use it?
What does $1 [QSA,L] mean in my .htaccess file?
Pretty URLs for search pages
The URLs we have currently look something like this:
example.com/search/?itemID=I-123456&itemName=FirstItemName+SecondItemName+MoreItemNames
I would like them to read something more towards this:
example.com/search/FirstItemName/SecondItemName/MoreItemNames/
Any guidance would be greatly appreciated. Thanks!
Basically I'm trying to figure out a way to make
http://www.mysite.com/check/google.com
show the contents of the page
http://www.mysite.com/check.php?site=test.com
and I want users to think that the actual URL is http://www.mysite.com/check/google.com instead of the long one.
But I need to do this in the friendliest way for Google so that they aren't looking at it as a redirect and it'll still rank well... Any help will be greatly appreciated if you can post some sample code... Thanks!
In the htaccess file in your document root, try adding:
RewriteEngine On
RewriteRule ^/?check/(.*)$ /check.php?site=$1 [L]
How can I change url in this way using htaccess?
http://www.domain.com/index.html?page=home
http://www.domain.com/indexf6f2.html?page=blog
To
http://www.domain.com/?page=home
http://www.domain.com/?page=blog
You could try to generate your own .htaccess file based on your rules using this site http://cooletips.de/htaccess/ .
Regards, Hiawatha
I am not giving exact solution. Just utilize the followings, then you will be able to solve other URL rewriting using .htaccess
Take help from the following URL
http://roshanbh.com.np/2008/03/url-rewriting-examples-htaccess.html
Other important regarding rewriting through .htaccess
http://corz.org/serv/tricks/htaccess2.php
RewriteRule to rename URL?
For a nice basic
http://www.yourhtmlsource.com/sitemanagement/urlrewriting.html
I'm pretty inexperienced with .htaccess so please bear with me.
I have a domain - "http://www.exampletest.com"
which redirects to a folder at a different domain where I have hosting i.e:
"http://www.differenturl.com/exampletest"
Is there an easy mod_rewrite rule where I could have anything at "http://www.differenturl.com/exampletest" show up as "http://www.exampletest.com?" An example would be:
"http://www.differenturl.com/exampletest/user.php" -> "http://www.exampletest.com/user.php"
Any assistance is greatly appreciated. I assume this easy so sorry to ask such a basic question.
Thanks
You say "rewrite, not redirect", so no, there isn't a simple way to do this. The only way to do what you ask would be to have a "reverse proxy" running on www.exampletest.com that fetches content from "www.differenturl.com/exampletest/". That isn't something you can do with mod_rewrite.
If I have understood correctly, following code might do:
RewriteRule exampletest/(.*)$ http://www.exampletest.com/$1 [R=301,L]
Please note that you add this line in the .htaccess file placed on differenturl.com server.
Hope that helps.
Cheers