Can someone help me with RegEx?
-
Hey!
I am having a tough time figuring this out, and I have already signed up for my RegEx course. So in the mean time, could you please help me?
I have two old URLs:
/faq
/faq.php
The new one is /faqs
How can I write a 301 redirect to include faq & faq.php in the same line? I basically want to capture /faq and anything beyond the q including the .php.
I thought this would work:
Redirect 301 /faq. http://www.blah.com/faqs
Using the period to catch everything after the q and redirect it to the /faqs page.
Extra credit: And why Redirect 301 vs. RedirectMatch 301? It is an Apache server and mod_ rewrite is on.
Thanks in advance!
-
Yes, I bet. I just want to be able to know what I'm asking. lol
Thanks again for your help!
-
-f is for file and -d is for directory, correct?
Correct.
And your very welcome
A course should help you understand RegEx a lot more but I still find myself looking up specific situations online.
-
Thanks Oleg!!!
-f is for file and -d is for directory, correct?
I found a 5 hour course on Lynda.com on RegEx so I'll be doing that this evening.
Thanks again for your quick response. Much appreciated!!!
-
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^faq(.*) /faqs [L,R=301]That should do the trick
-
I'm going to have to do a rule, aren't I? Basically to include (faq|faq.php) or something like that, huh? So a RewriteRule is going to have to be used instead of Redirect or RedirectMatch.
Please help!
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
-
How can I fix a SSL that is redirecting 3 times?
I have url that is redirecting three times. How do I fix that? I am using WP and running Really Simple SSL plugin. Is it ok to use the redirect plugin also? See here what the problem is: http://www.thepatrickmullin.com/ redirects to https://thepatrickmullin.com/ through a redirect chain. This hurts your rankings http://www.thepatrickmullin.com/ -->
Intermediate & Advanced SEO | | pmull
https://www.thepatrickmullin.com/ -->
https://thepatrickmullin.com/ Any help would be greatly appreciated!0 -
Can you give me some advices to rank this domain?
Hi Moz community, I've a coleague that's working to rank this site: www.devsar.com. The selected keywords are:
Intermediate & Advanced SEO | | Gaston Riera
Mobile development
Web development
Django Development
Python Development I've checked the site: It's fast and clean. Has a good PA and DA. It's responsive and good lookking. Meta description , title, hreflang.. everything in order. Link profile a little rare (checked with ahref.com), it's because someone made a mistake redirecting some expired domain Can you help me to help my mate out?
Thanks
GR.0 -
Video SERP Help
Hello Friends,
Intermediate & Advanced SEO | | KINQDOM
I try to appear on search results of property related search terms with my property videos. Here is a sample property video
http://www.antalyahomes.com/videositemap.asp May you please check it and tell me what I do wrong? Thanks in advance for your time.0 -
Large site rel=can or no-index?
Hi, A large site with tens of thousands of pages, but lots of the pages are very similar. The site is about training courses, and the url structure is something like: training-course/date/time I only really want the search engines to index the actual training course pages, which is the better option for me and why?: a) rel=canonical b) noindex, nofollow Thanks, Gary.
Intermediate & Advanced SEO | | cottamg0 -
Title Tag Help
Hi everyone, So, I have some general question's about Title tags. My question's are as follows: 1. If i have a title tag like this 'Commercial bathroom instillation '. Will I show up for Commercial bathroom or Commercial bathroom instillation? The reason I ask is, i'm aiming for Commercial bathroom which has more search volume, but here is where the problem comes in. If I have Commercial bathroom instillation it is a more compelling title. Ideally i'm aiming for Commercial Bathroom, so im in a bit of a conundrum, as you can see. 2. My second question is if I have 'Bath Review and Shower review' for my title tag. Will I show up for Bath Review individually, and shower review individually, or only when someone search's that exact query? I hope that makes sense thanks. Peter
Intermediate & Advanced SEO | | PeterRota0 -
SEO & Magento Multistore - I have been asked if "duplicatiing" a magento stor using its "Multistore" functionality will cause both to be picked up as duplicate content, can anybody help?
Hello all. I have been asked what the consequences of using Magento's "multistore" functionality are if we were to duplicate our entire magento store and place it on a secondary domain... The simple answer which comes to my mind is that it will be a flagged as duplicate content. However, is this still the case if the site were placed in a different country? The original being the UK the copy being Ireland (both English speaking) How would Google.co.uk & Google.ie treat these stores? Hope this is clear... our site is http://www.tower-health.co.uk
Intermediate & Advanced SEO | | TowerHealth0 -
Can you appear in both Google local and universal results on the page?
I have a client that ranks 2nd for a google local result, and the local results are the first set of results being displayed, making it in fact the 2nd result on the page for the keyword. There aren't any blended results on this page, it's straightforward local results, then universal results directly after. They are concerned that they are not appearing in the universal results high enough (they're on page 5 with a different url than the homepage). I'm not sure why their #2 local ranking isn't good enough since those are consistently the same results, but I have to ask; Can you appear in both local and universal results on the same page?
Intermediate & Advanced SEO | | MichaelWeisbaum0 -
How 'Off Topic' can I go - site wide?
Hello, I am currently number 1 for a competitive keyword - so don't want to push the wrong button and self destruct! My site is highly focused on one relatively narrow niche with about 50-60 pages of content bang on topic. I was wondering if Google will discredit my site in any way if I start adding pages that are** 'loosely related' **to the overall theme of my niche. Some of them are what you might call sister concepts with maybe one mention of my target keyword in the body..... Does the algo value what percentage of the whole site's content is on/ off topic? If so how important is this as a factor? Thanks a lot
Intermediate & Advanced SEO | | philipjterry0