URL Rewrite
-
Using the .htaccess file how do I rewrite a url from
www.exampleurl.com/index.php?page=example
to
removing index.php?page=
Any help is muchly appreciated
-
I would mark this question as answered, it seems that a lot of great minds have come together and given a lot of really accurate responses. It just keeps others from re-answering.
-
You have to setup a new URL. The rewrite only redirects traffic. If the page doesnt exist you are redirecting traffic to a page that doesn't exist. No Bueno!
-
I had a similar problem and found this site particuarly useful: http://httpd.apache.org/docs/2.0/misc/rewriteguide.html
Works great for me now. Good Luck.
-
Thanks for that pointer goonewscowboy, I just stumbled across this article and it was a good read
-
This line should exclude that part: index.php?page=
Just try if it works.
-
URL rewriting is a common and safe practice and as goodnewscowboy points out: http://www.seomoz.org/ugc/a-simple-guide-to-htaccess - just test it and see that nothing funky is going on with your site and note that the above examples are not customised to your particular site / page structure.
Search engines are good with picking up 301s for new pages. If your pages are already in index and have links the only downside is that you may lose a bit of anchor text focus (I remember Matt Cutts talking about this in one of his videos) but link juice should pass through just fine.
-
Hiya Craig: This post from YOUmoz might help you to be able to wrap your mind around it better.
-
Will this have any negative effect in the serps?
-
RewriteEngine on RewriteRule ^page/([^/.]+)/?$ index.php?page=$1 [L]
If you're using the numbered (e.g. page=102) IDs:
RewriteEngine On RewriteRule ^article/([0-9]+)/? article.php&article=$1 [R=301, L]
-
This is what the current file looks like if it helps
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
-
And do I have to set up a new url or does it actually rewrite the existing URL?
I really can't get my head round this
-
What about:
RewriteRule ^index.php?page=(.*)$ /$1 [R=301,L]
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
Browse Questions
Explore more categories
-
Moz Tools
Chat with the community about the Moz tools.
-
SEO Tactics
Discuss the SEO process with fellow marketers
-
Community
Discuss industry events, jobs, and news!
-
Digital Marketing
Chat about tactics outside of SEO
-
Research & Trends
Dive into research and trends in the search industry.
-
Support
Connect on product support and feature requests.
Related Questions
-
URL is invalid: Why?
Hello everyone, I am currently listing my company on business directories. For some websites however when I add my website URL, it comes up as URL is invalid. What could be the reason for this? I have tried different variations like www., http:// and https://. Kind Regards,
Technical SEO | | SMCCoachHire
Aqib0 -
URL gets cut off in Google
Hi everybody, I got a question concerning my website URLs. It's a large WordPress website and we've got a lot of categorised pages ('parent' / 'child'). Now when I search for a specific page I only get to see the 'parent' name in the URL. The page which I am looking for isn't visible. Only a small arrow which shows me 2 options (in cache and compare). The URLs are not too long. Does anybody know why this happens, and how I can solve it? I added a image for reference. (Where /partners/ is the parent page and /partners/aruba/ isn't visible) Thank you very much. LSsT1Ua
Technical SEO | | SecureLink0 -
Error in how URLs were set up, how can it be fixed?
Hi, I managed a website port to a WP responsive deisgn for a client, see http://chicagotelephony.com. Unfortunately, he wanted me to work with a graphic designer rather than a web geek, so the resulting website has messed up URLS, i.e. index.php is smack in the middle of almost all the pages. I know that is all wrong, but I also realized that she was not fluent in the way the Genesis framework was set up or how the particular template I selected, operated. So I just wanted to get it out there.... and now it is live, but has all these errors. Do I have to do 301 redirects? Is there a setting or a button inside of the WP template that would put correct slugs but get rid of the index.pho within the URL? For example, http://chicagotelephony.com/index.php/cloud-based-solutions/ and http://chicagotelephony.com/index.php/var-network-value-added-reseller/ should be chicagotelephony.com/cloud-based-solutions/ and chicagotelephony.com/var-netowrk-value-added-reselle/ and so forth.
Technical SEO | | DianeDP0 -
Changing URL - Ranking Disappeared?
Hi All, I named a page URL /plectrums/ within the back end framework. But then decided to change it to /personalised-plectrums/ I resubmitted a GWT sitemap and 301 redirected plectrums -> personalised-plectrums My ranking for personalised plectrums has disappeared and has not come back does anyone know why this is? Or is there something I have missed? Lewis
Technical SEO | | SO_UK0 -
URL removals
Hello there, I found out that some pages of the site have two different URL's pointing at the same page generating duplicate content, title and description. Is there a way to block one of them? cheers
Technical SEO | | PremioOscar0 -
Mobile URLs in the desktop SERPs
Our real estate website URL is listed on desktop search as well as the mobile URL. I've read several blogposts on this subject but I still don't understand the fix for this. I've read to use rel=canonical tags. But does that stop Google from listing it in the desktop SERP? Is there a way to stop this without blocking the mobile site which is what our programmer wants to do? Or is this something we have to live with until Google fixes this issue?
Technical SEO | | MassMedia0 -
Home page URL
Hi, I work on this site: http://www.towerhousetraining.co.uk/about-us. This is the home page URL. Should this be 301'd to: http://www.towerhousetraining.co.uk? I have created a site map, which I submitted to Google Webmaster Tools, which includes these URL's: /about-us, /training-we-offer & /contact-us. There are a total of 3 pages on the website. Webmaster tools has only indexed 2 out of 3 pages. I think this is something to do with the /about-us URL, as when I do a site: search, these pages appear: www.towerhousetraining.co.uk/, /training-we-offer & /contact-us. I am not sure why Google has indexed the home page as www.towerhousetraining.co.uk/ and not /about-us? Is it a bad idea in general not to have your homepage as your root domain? I added a to the homepage, but am wondering if this was the right thing to do? Any help would be appreciated.
Technical SEO | | CWseo0 -
Re-write of url
Hi, I would like your input on the following dilemma I am wanting to target the keyword "download xml". at the moment Google indexes us on page 2 and indexes the page www.ourdomain.com/download.aspx I would like to rewrite the url to be /download-xml-editor.aspx The current page is a pr5 and is our most trafficked and externally inked to page. My thoughts are quite mixed on how to do this. approach 1: re-write url of "download.aspx" and setup permanent 301 redirect of download.aspx to download-xml-editor.aspx approach 2: create a new page called download-xml-editor and 301 redirect that to the current stronger page which is download.aspx approach 3: create new page called download-xml-editor with unique content and try and get that page to rank over time, allowing it to build up links and not compromise the current page, then later 301 redirect How would you deal with this and what are your recommendations
Technical SEO | | LiquidTech0