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
-
Duplicate Content - Different URLs and Content on each
Seeing a lot of duplicate content instances of seemingly unrelated pages. For instance, http://www.rushimprint.com/custom-bluetooth-speakers.html?from=topnav3 is being tracked as a duplicate of http://www.rushimprint.com/custom-planners-diaries.html?resultsperpg=viewall. Does anyone else see this issue? Is there a solution anyone is aware of?
Technical SEO | | ClaytonKendall0 -
URL Change, Old URLs Still In Index
Recently changed URLs on a website to remove dynamic parameters. We 301'd the old dynamic links (canonical version) to the cleaner parameter-free URLs. We then updated the canonical tags to reflect these changes. All pages dropped at least a few ranking positions and now Moz shows both the new page ranking slightly lower in results pages and the old page still in the index. I feel like I'm splitting value between the two page versions until the old one disappears... is there a way to consolidate this quickly?
Technical SEO | | ShawnW0 -
How important is keyword usage in the URL?
Hi,
Technical SEO | | Whebb
We have a client who has engaged us recently for some SEO work and most of their website looks pretty good seo-wise already. Many of their site pages rank at the top or middle of page two for their targeted keywords. In many cases they are not using the targeted keyword in the URL and most pages could use some additional on-page clean up. My question is, is it worth it to re-write the URLs to include the targeted keyword and then do 301 redirects to send the old pages to the new ones in order to improve the ranking? Or should we just do the minor on page work in hopes that this will be enough to improve the rankings and push them on to the first page. Thanks.0 -
Making URLs automatically clickable
Hi all, I have a PHP function which i use to make all links clickable. Problem is, if some one writes a link in a a-tag, the URL inside the href value is made clickable. Not good. Can someone perhaps help me with the issue? Function: function makeClickableLinks($text)
Technical SEO | | rasmusbang
{
$text = preg_replace('/<//', ' $text = preg_replace('(
)', '
', $text);
$text = preg_replace('!((https?://www.|https?://|www.)(([a-z0-9-]+.)+[a-z]{2,6})(/\S+|/)*)!ie', '"[".shortenurl("\1")."]("".(strtolower('$2'))"', $text);
$text = str_replace('( <a href',="" '<a="" $text);<br="">$text = str_replace(')" target', '" target', $text);
$text = str_replace('):" target', '" target', $text);
$text = str_replace(')..." target', '" target', $text);
$text = str_replace(').." target', '" target', $text);
$text = str_replace(')." target', '" target', $text);
return $text;
}</a> <a href',="" '<a="" $text);<br="">Pleeeeease heeelp 🙂 Can't fix it on my own - been at it for ages. -Rasmus</a>0 -
No Keyword in URL
SEOMoz (and other platforms) advise that I need to add my keyword to the page URL, however as far as I'm concerned it has been, so why don't these platforms see it. My home page URL is www.salesandinternetmarketing.com, but apparently I haven't added the keyword internet marketing to the URL, what advice can you give me please? Lindsay
Technical SEO | | lindsayjhopkins1 -
Keyword and URL
I have a client who has a popular name (like 'Joe Smith'). His blog URL has only his first name and the name of his company in it, like joe.company.com. His blog doesn't rank well at all in the first 3-4 Google SERPs. I was thinking of advising him to change the URL of his blog to joesmith.company.com, and having his webmaster do 301 redirects from the old URL to the new one. Do you think this is a good strategy, or would you recommend something else? I realize ranking isn't just about the URL, it's about links, etc. But I think making his URL more specific to his name could help. Any advice greatly appreciated! Jim
Technical SEO | | JamesAMartin0 -
Negative url name?
I have a new client who has the letters "BB" at the start of his url name, bbzautorepair.com. He was told by someone at Google Adwords that the letters "BB" in his url name could hurt him with Google rankings. Reason being that Google red flags anything or website to do with firearms, guns and ammunition. He was told that the letters "BB" could be mistaken or red flagged for "BB Gun". Seems a bit far fetched. Has anyone every heard of such a thing? Thanks
Technical SEO | | fun52dig
Gary Downey0 -
What are the impact of doing URL Rewriting instead of 301 redirections whille optimizing a blog?
In WordPress, with the ALL In ONE SEO pluggingm we've optimze the permalinks to show more keewords in the URL'. What can be the impact?
Technical SEO | | webit400