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
-
Can Someone explain why this site ranks #1 and #2? I am confused.
Hi everyone, Here is my problem. This site: https://247ride.com/town-cars/ ranks for bunch of really good keywords. Such as lax car service, car service to lax etc. The keyword does not appear in Title tag, and only partially on meta description. The site's DA is 23 and PA is 22. Less than 29 links overall, and linking domains 8. Why in your opinion Google is ranking this page #1 and #2 for many competitive keywords. I know it's a hard question to ask but any input would be greatly appreciated. I am working really hard to rank for same keywords and so far i am at #11 position. Thanks in advance, Davit
Intermediate & Advanced SEO | | Davit19851 -
Can I cover any topic(s) or are they some required ones
Can you talk about anything (any topics) when you write about something or is google expecting to see certain topics ? Let me clarify, let's say I do "bike tours on the island of Corsica"and bike through villages that none of the companies ranking on the 1 st page ride thru. Can I still rank as long as I write good content or do I need to cover at least some of the topics covered by the companies ranking on the 1 st page ? Thank you,
Intermediate & Advanced SEO | | seoanalytics0 -
Can't diagnose this 404 error
Hi Moz community I have started receiving a load of 404 errors that look like this: This page: http://paulminors.com/blog/page/5/ is linking to: http://paulminors.com/category/podcast/paulminors.com which is a broken link. This is happening with a load of other pages as well. It seems that "paulminors.com" is being added to the end of the linking pages URL.I'm using Wordpress and the SEO by Yoast plugin. I have searched for this link in the source of the linking page but can't find it, so I'm struggling to diagnose the problem. Does anyone have any ideas on what could be causing this? Thanks in advance Paul
Intermediate & Advanced SEO | | kevinliao0 -
Content Of Dead Websites Can be resused?
I have 2 websites. One website links are from spamy techniques (wrong guy hired) which still has massive links so I started a new website with a fresh domain. Now when the new website (only white hate methods used) has started to show positive movements I feel like its the right time to shut the other website down. Since, I have a lot of content on my first site (spamy links) can i reuse the content again on my new site after I shut down my first site?
Intermediate & Advanced SEO | | welcomecure0 -
SEO: Can you rank Amazon product Pages ?
Hi Guys Just a general question about doing SEO for our product pages... We have a range of products on Amazon and wondered if it is worth build some good links to our product pages to get them ranked higher in Google ?? Is it easier to rank Amazon product pages ?? Thanks Guys G Gareth
Intermediate & Advanced SEO | | GAZ090 -
Can I tell Google to Ignore Parts of a Page?
Hi all, I was wondering if there was some sort of html trick that I could use to selectively tell a search engine to ignore texts on certain parts of a page. Thanks!
Intermediate & Advanced SEO | | Charles_Murdock
Charles0 -
Magento Help - Server Reset
Good Morning, After rebooting a server, a magento based website reset itself going back to December 2013. All changes to the site and orders dating up until yesterday (6/19/14) have disappeared. There are several folders on the root of the server that have files with yesterday's date but we don't know how to bring everything back and restore. Any Magento or server experts out there ever face this issue or have any ideas or potential solutions? Thanks
Intermediate & Advanced SEO | | Prime850 -
Dynamic numbers in meta title - can it harm SEO?
We are creating an online shop with thousands of products. And i want to put total product number in index title, each day/week it will increase. This would be interesting for visitors to see. But would be it be good for SEO? For example title: "Brand - Buy Toys Online, We Have More Than 10659".
Intermediate & Advanced SEO | | bele0