Htaccess query
-
I'm currently working on a live version of a clients website which has duplication issues. With .htaccess, I need to rewrite URL's of the following format:
vacancy.php?id=802 to vacancy/?id=802
I tried adding the following line but it returned a 500, and don't want to keep taking the site out.
RewriteRule ^vacancy/?id=([0-9]+)$ vacancy.php?id=$1 [R=301, L]
-
Hi again Matt,
Actually, you don't need to be using the 301 at all. A simple rewrite will do what you are wanting.
If you do it like this:
RewriteRule ^vacancy/([0-9]+)$ vacancy.php?id=$1 [L]
your URLs would be a lot more friendly.
The resultant URLs would look like this:
/vacancy/12345
Hope that helps,
Sha
-
Hi Matt,
The 500 Error is caused by the "space" in [R=301, L]
Should be [R=301,L]
Hope that helps,
Sha
-
Hi,
please back up your .htaccess before attempting
Redirect match might work, but only if you are redirecting all to one - Keep in mind the initial directive needs to be changed to your specific scenario, as well as the destination URL
RedirectMatch 301 ^page.php?id=(.*).htm$ http://www.example.com/content/$1.html
Or you could do it one by one -
RewriteCond %{QUERY_STRING} ^id=1$
RewriteRule ^page.php$ http://www.example.com/content/page? [R=301,L]Or here is a link to a resource (I HAVE NOT TESTED OR USED) but gets lots of good feedback, for helping you make easier work out of hundreds of dynamic redirects
http://www.mbstrategic.com/02/301-redirects-for-dynamic-urls-to-static-pages-with-htaccess/
Hope this helps
PS after a seconf look, your initial attempt might work, you just need a condition which would be similar to
RewriteCond %{QUERY_STRING} ^id=1$
-
Sorry, I should have been more clear. There are hundreds of vacancy ID's which change over time, so I need to use a rewrite rule to handle all cases now and in the future.
-
Here's the format you may need to follow, I'm not 100% positive this will work for you but I know this is how 301s are setup:
redirect 301 vacancy.php?id=802 **yourdomain.com/path-to-location/**vacancy/?id=802
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
-
Does anyone know a way to restore data more than sixteen months old from GSC or extract more than 1000 queries.
Does anyone know a way to restore data more than sixteen months old from GSC or extract more than 1000 queries?
Technical SEO | | RossKernez0 -
Server redirect query
Hi there, due to so much traffic coming through to our e-commerce site our host is going to do an apache re-direct for over flow traffic from www.mywebsite.com to a ww2.mywebsite.com canonical tags will be in, but if there is a re-direct this is surely bad for seo, telling on onccasions the page has moved? Any advice on this and the best way to re-direct users when there is too much traffic please let me know.
Technical SEO | | pauledwards0 -
A query about internal linking. Have I got this right?
Hi Guys I think this sounds like a right noobie question, but I am amongst friends so here goes. So our website is an ecommerce site selling magazines. There are certain magazines, for example Vogue, where we sell the UK version, USA, italian, spanish, french etc there's basically 13 different Vogue magazines on our site. The more niche ones attract some good long tail traffic. However, the UK version is competitive and so requires some extra umph to get us a half descent rank. However, when you search "vogue magazine subscription" for example, it's our italian vogue which is listed first. When I looked into this, I found that we had linked out from our UK Vogue to Italian vogue. Could this have given the italian vogue a marginal boost, as it had the additional internal links? What I have now done is add to some, not all, of the variations something along the lines "you will find the UK Vogue magazine here" where "UK Vogue Magazine" is the anchor text. Is this the right thing to do? Will this identify that the UK Vogue page is the higher priority page, or the more important page? I was also going to add to a category page a "Top 10 Womens magazines" section, and link to Vogue from there. Am I barking up the right tree? Thanks Guys Paul
Technical SEO | | TheUniqueSEO0 -
Htaccess Rewrites
Hi, I'm battling with duplicate content and would love to fix some redirections in my htaccess file: 1. I'm trying to use the www version of my site via 301 2. I'm trying to remove ALL /index.php from my url's I currently have the following code, but my home page /index.php is still not redirecting to the root? Options +FollowSymLinks
Technical SEO | | Klement69
Options +Indexes <ifmodule mod_rewrite.c="">RewriteEngine On
#RewriteBase / RewriteCond %{HTTP_HOST} ^funeralcoverfinder.co.za$ [NC]
RewriteRule ^(.*)$ http://www.FuneralCoverFinder.co.za/$1 [R=301,NC,L] RewriteCond %{QUERY_STRING} base64_encode[^(]([^)]) [OR]
RewriteCond %{QUERY_STRING} (<|%3C)([^s]s)+cript.(>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|[|%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|[|%[0-9A-Z]{0,2})
RewriteRule .* index.php [F] RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} /component/|(/[^.]|.(php|html?|feed|pdf|vcf|raw))$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]</ifmodule> Any Advice? - Thanks so much!0 -
Htaccess file
I need to redirect the web pages which do not exist to 404 error the task need to be done in htaccess file. I am using Linux server. the webpages I want to redirect is my domain name followed by question mark e.g. www.mydomain.com/?dfdds I am using the following snippet in my htaccess file, it redirect to bing.com so far, please tell me how to change the snippet so that it redirect to redirect to 404 error page. ========================== RewriteCond %{QUERY_STRING} . RewriteRule .* http://www.bing.com? [L,R]
Technical SEO | | semer0 -
URL query considered duplicate content?
I have a Magento site. In order to reduce duplicate content for products of the same style but with different colours I have combined them on to 1 product page. I would like to allow the pictures to be dynamic, i.e. allow a user to search for a colour and all the products that offer that colour appear in the results, but I dont want the default product image shown but the product image for that colour applying to the query. Therefore to do this I have to append a query string to the end of the URL to produce this result: www.website.com/category/product-name.html?=red My question is, will the query variations then be picked up as duplicate content: www.website.com/category/product-name.html www.website.com/category/product-name.html?=red www.website.com/category/product-name.html?=yellow Google suggest it has contingencies in its algorithm and I will not be penalised: http://googlewebmastercentral.blogspot.co.uk/2007/09/google-duplicate-content-caused-by-url.html But other sources suggest this is not accurate. Note the article was written in 2007.
Technical SEO | | BlazeSunglass0 -
Broken links shall i put them in my htaccess file to generate juice
Hi, when i had to rebuild my website after my hosting company made an error, i lost over 10,000 pages and lost many thousands of links coming to my site. What i want to know is, instead of trying to recreate those pages again which would take me a long time, should i put them into my htacess file and have them point back into my site. so for example, if i have a link coming to my site to an article which could be, holidays in benidorm are not selling well, would it be a good idea to have that link pointed at the main benidorm section which is benidorm news. And if i had an article which was people are finding it hard to lose weight, instead of writing a new article could i have the link pointing to my health section? If this is the correct way of doing it to grab back some link juice, would it slow my site down and how many links could i put in my htacess file. So what i am trying to say is, if i put in say 1000 redirects into my htaccess file, would it slow my site down and is this a wise thing to do or should i just let the links go.
Technical SEO | | ClaireH-1848860 -
Microformats & Schema.org query
Just finished watching the Microformats & Schema.org webinar (thanks for a good presentation Richard) and picked up some interesting tips. It did get me thinking about ways I could use them with a couple of ecommerce sites I am working on. At present there are no reviews on the page so cannot add that tag, however the product pages have a facebook like and a tweet option so maybe I could add a tag based around that? Another one I am considering is putting the sizes of the items in one 'available in sizes 12-32' for example as women often ponder if a store will have it in their size. I guess my question is, would these ways of using it be considered too spammy. I note the webinar state using microformats can be useful but there is a risk if they are too spammy etc. Any opinions would be most welcome, Carl
Technical SEO | | Grumpy_Carl0