Htaccess redirect veriables
-
Hey,
I'm trying to redirect all instances of "/archive_details.php?id=*" to "/public-affairs-job-archive.php". Is the below code correct?
Redirect 301 /archive_details.php?id=* /public-affairs-job-archive.php
Thanks, Luke.
-
Exactly what i was looking for.
Thanks!
-
Your construction is not correct because the second parameter in your redirect, the url you are redirecting to, needs to be the full url, like this: http://www.yourdomain.com/public-affairs-job-archive.php
If you need to redirect any URLs matching a phrase you can use RedirectMatch -it performs a regular expression redirect.
In your case the redirect will look like this:
RedirectMatch 301 /archive_details.php?id=(.*) http://www.yourdomain.com/public-affairs-job-archive.php
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
-
Redirect question | new blog install on subdomain
Hi, I am running a wordpress site and our blog has grown to have a bit of a life of its own. I would like to use a more blog-oriented wordpress theme to take advantage of features that help with content discoverability, which is what the current theme I'm using doesn't really provide. I've seen sites like Canva, Mint and Hubspot put their blog on a subdomain, so the blog is sort of a separate site within a site. Advantages I see to this approach: Use a separate wordpress theme Help the blog feel like its own site and increase user engagement Give the blog its own name and identity My questions are: Are there any other SEO ramifications for taking this approach? For example, is a subdomain (blog.mysite.com) disadvantageous somehow, or inferior to to mysite.com/article-title? Regarding redirects, I read a recent Moz article about how 301s now do not lose page rank. I would also be able to implement https when I redirect, which is a plus. Is this an ok approach? Assuming I have to create redirect rules manually for each post though Thanks!
Intermediate & Advanced SEO | | mikequery0 -
Code to Redirect Mobile Subdomain to Desktop Site
Hi Everyone, My client is switching from a mobile subdomain to a responsive site. All URLs are the same on mobile subdomain vs desktop so we just need a wildcard rule to redirect m. to www. Anyone have this wildcard redirect code for an .htaccess file? Much appreciated! Dan
Intermediate & Advanced SEO | | kernmedia0 -
Getting SEO Juice back after Redirect
Hi, On my website, many product pages were redirected over time to its product category, due to the product being unavailable. I understand with a 301 redirect, the final URL would have lost about 15% of the link juice. However - if after some time (e.g. 2 months, or 1 year) I remove the redirection - is the original page going to have any SEO juice, or did it already lose all of it? Thanks,
Intermediate & Advanced SEO | | viatrading10 -
301 redirects for a redesign.
About to completely redo a client's site and I want to make sure I don't loose our link juice. The current site is a old template site from another provider. They host it and we do not have access at all to the site itself, so there will be no transferring of the site from server to server because they feel the site is their property. Basically the site is a monthly service not a product. So this will be a completely new website, including new URL structure. So my question is how do keep the link juice flowing to the new site? I know I need to use 301 redirects, but do I rebuild those old URLs on my site and redirect them to their new counterpart or what? The link profile is not that impressive, maybe 15 back links (all mainly going to the homepage). But they all are local and coming from pretty good domain authority. But its keeping us ahead of our competition. Back story: This is one of my local search clients, we now have them ranking #1 across the board in the local packs. After analyzing the traffic, they are losing 75% of all traffic because of the sites design. So a new site is a must. I build a lot of websites, but have never worried about the back link profile before now. Thanks for all your help!
Intermediate & Advanced SEO | | masonrj0 -
Best .htaccess guides in your bookmark?
It would be helpful if you can share .htaccess guides you're currently using. Thanks in advance! 🙂
Intermediate & Advanced SEO | | esiow20130 -
301 redirect on Windows IIS. HELP!
Hi My six-year-old domain has always existed in four forms: http://www**.**mydomain.com/index.html http://mydomain.com/index.html http://mydomain.com/ http://www.mydomain.com My webmaster claims it’s “impossible” to do a 301 redirect from the first three to the fourth. I need simple instructions to guide him. The site’s hosted on Windows running IIS Here’s his rationale: These are all the same page, so they can’t redirect to themselves. Index.html is the default page that loads automatically if you don’t specify a page. If I put a redirect into index.html it would just run an infinite redirect loop. As you can see from the IIS set up, both www.mydomain and mydomain.com point to the same location ( VIEW IMAGE HERE ) _Both of these use index.html as the default document ( VIEW IMAGE 2 HERE ) _
Intermediate & Advanced SEO | | Jeepster0 -
Is there a way to redirect pages from an old site?
I have no access to an old wordpress site of a client's, but have parked the domain on their new site, gone into webmaster central and requested a change of address and wait... the old domain still shows in the search listings in place of the new site domain and the log files show 404 errors from links to the old site which go nowhere - can anyone suggest a way of managing this on the new site - is there a workaround to what should have been done - 301 redirects on the old site before it was taken down. many thanks
Intermediate & Advanced SEO | | Highlandgael0 -
How to Redirect
What is the htaccess code to redirect everything in a directory to a file? Thanks!
Intermediate & Advanced SEO | | tylerfraser0