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 301 Re-direct
Hello, If we publish a blog post with a url which accidentally contains a number at the end (blog.companyname.com/subject-title-0), is it best-practice to update the URL (e.g. to blog.companyname.com/subject-title) and put in a 301 re-direct from the old to the new one or should it simply be left as is? I've read that 301's lose link equity and relevance so is it really worth re-directing for the sake of a cleaner url? Thanks for your input! John
Technical SEO | | SEOCT1 -
Site scraped over 400,000 urls
Our business is heavily dependent on SEO traffic from long tail search. We have over 400,000 pieces of content, all of which we found scraped and published by another site based out of Hong Kong (we're in the US). Google has a process for DMCA takedown, but doing so would be beyond tedious for such a large set of urls. The scraped content is outranking us in many searches and we've noticed a drastic decrease in organic traffic, likely from a duplicate content penalty. Has anyone dealt with an issue like this? I can't seem to find much help online.
Technical SEO | | Kibin0 -
Old URLs Appearing in SERPs
Thirteen months ago we removed a large number of non-corporate URLs from our web server. We created 301 redirects and in some cases, we simply removed the content as there was no place to redirect to. Unfortunately, all these pages still appear in Google's SERPs (not Bings) for both the 301'd pages and the pages we removed without redirecting. When you click on the pages in the SERPs that have been redirected - you do get redirected - so we have ruled out any problems with the 301s. We have already resubmitted our XML sitemap and when we run a crawl using Screaming Frog we do not see any of these old pages being linked to at our domain. We have a few different approaches we're considering to get Google to remove these pages from the SERPs and would welcome your input. Remove the 301 redirect entirely so that visits to those pages return a 404 (much easier) or a 410 (would require some setup/configuration via Wordpress). This of course means that anyone visiting those URLs won't be forwarded along, but Google may not drop those redirects from the SERPs otherwise. Request that Google temporarily block those pages (done via GWMT), which lasts for 90 days. Update robots.txt to block access to the redirecting directories. Thank you. Rosemary One year ago I removed a whole lot of junk that was on my web server but it is still appearing in the SERPs.
Technical SEO | | RosemaryB3 -
Mobile update: referrer in alternate URL
Hi there, A little while ago I posted a question about the upcoming mobile update. I am convinced about the fact that I must work on a solution before the update rolls out since a substancial part of our traffic has come from mobile devices. My current issue: our webshop host is not willing to cooperate with the best possible solution our mobile webshop partner proposes. This was the plan: This is the only possible solution now: The element 'request.url' will contain the full desktop URL which 301 redirects to the mobile URL. My question is: will google have problems with the 301 redirect which refers to the right mobile URL? Thanks in advance.
Technical SEO | | MarcelMoz
Marcel0 -
Preserving Social Shares Through URL Changes
We are making significant URL changes to our website. Because the URL is changing the social sharing buttons are not showing previous shared counts. I have read several resources like the one below that is linked to in several other similar questions. http://searchenginewatch.com/article/2172926/How-to-Maintain-Social-Shares-After-a-Site-Migration However I would love to get some insight from someone who has done this and there thoughts on the outcome. As an ecommerce site the "Social Proof" of products that have received social shares is a big deal to us. In Mike Kings example above the counts are being attributed to the OLD URL which is problematic over time. Our site has been up for over 12 years and has had several major changes to it, and I am certain there will be more in the future, being able to preserve the count on the current URL is ideal. While I agree with him that over time I believe social platforms will let data pass through 301 redirects, until then I need to find the best way to do this. Also with his example and others I have seen people mention than new likes from the new url can reset the counter. If you have gone through this and have ideas pleas share them. I look forward to your thoughts thanks.
Technical SEO | | RMATVMC1 -
Add selective URLs to an XML Sitemap
Hi! Our website has a very large no of pages. I am looking to create an XML Sitemap that contains only the most important pages (category pages etc). However, on crawling the website in a tool like Xenu (the others have a 500 page limit), I am unable to control which pages get added to the XML Sitemap, and which ones get excluded. Essentially, I only want pages that are upto 4 clicks away from my homepage to show up in the XML Sitemap. How should I create an XML sitemap, and at the same time control which pages of my site I add to it (category pages), and which ones I remove (product pages etc). Thanks in advance! Apurv
Technical SEO | | AB_Newbie0 -
Are you allowed to point different urls to same page
hi, i have some urls that i am either going to put on hold or thinking about pointing to one of my sites. what it is, i am looking at re-designing the pages but not until next year, so i thought i would point some of the urls to a site that i am happy with to different pages, but not sure if i am allowed this or not so for example, if i have a site on cars, and one of the url is www.rovercars.co.uk i was thinking about pointing it to the page that is about rover cars. can anyone let me know if this is allowed or not please
Technical SEO | | ClaireH-1848860 -
Htaccess rewrites
We’re using wordpress, and we have the following in the .htaccess: BEGIN WordPress RewriteEngine On RewriteBase / RewriteRule ^index.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] END WordPress We have a URL like http://subdomain.example.com/select-a-card/?q=fuel, and I want to rewrite it so that it becomes http://subdomain.example.com/fuel-card/ What do I need to add to the htaccess to do this?? Thanks,
Technical SEO | | AndrewAkesson0