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 I data highlight pages that already have schema?
Hi all, I have pages with schema on but there are some gaps. Rather than ask my dev team / wait for the changes to be made, can I use the data highlighting tool in GSC to fill in these gaps? Will it let me add these and will Google generally consider both the schema and the highlighted data? To note, if I have used GSC to highlight data and then test it in Google's Structured Markup Test Tool it won't show so I understand it may be difficult to test whether it's working or not. Any advice would be appreciated. Thanks!
Intermediate & Advanced SEO | | KJH-HAC0 -
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 -
Can someone help me understand why this page is ranking so well?
Hi everyone, EDIT: I'm going to link to the actual page, please remove if there are any issues with confidentiality. Here is the page: https://www.legalzoom.com/knowledge/llc/topic/advantages-and-disadvantages-overview It's ranking #2 on Google for "LLC" This page is a couple months old and is substantially heavy in content, but not much more so than all the dozens of other pages online that are competing with it. This is a highly competitive industry and this particular domain is an extremely huge player in this industry. This new page is suddenly ranking #2 for an extremely competitive head term, arguably the most important/high volume keyword being targeted by the entire site. The page is outranking the home page, as well as the service page that exactly targets the query - the one that you would think would be the ranking page for this head term. However, this new page is somewhat of a spin-off with some additional related content about the subject, some videos, resources, a lot of internal links, etc. The first word of the title tag exactly matches the head term. I did observe that almost no other pages on the site have the exact keyword as the first word of the title tag, but that couldn't be sufficient to bring it up so high in the ranks, could it? Another bizarre thing that is happening is that Google is ignoring the Title Tag in the actual HTML (which is a specific question that is accurate to the content on the page), and re-assigning a title tag that basically looks like this: "Head Term | Brand." Why would it do this on this page? Doesn't it usually prefer more descriptive title tags? There are no external links coming up on Moz or Majestic pointing to this page. It has just a couple social shares. It's not being linked to from the home page or top nav bar on the main site. Can anyone explain how this particular page would outrank the main service page targeting this keyword, as well as other highly authoritative, older pages online targeting the same keyword? Thanks for your help!
Intermediate & Advanced SEO | | FPD_NYC1 -
Does anyone know of any tools that can help split up xml sitemap to make it more efficient and better for seo?
Hello All, We want to split up our Sitemap , currently it's almost 10K pages in one xml sitemap but we want to make it in smaller chunks splitting it by category or location or both. Ideally into 100 per sitemap is what I read is the best number to help improve indexation and seo ranking. Any thoughts on this ? Does anyone know or any good tools out there which can assist us in doing this ? Also another question I have is that should we put all of our products (1250) in one site map or should this also be split up in to say products for category etc etc ? thanks Pete
Intermediate & Advanced SEO | | PeteC120 -
Can we have differnt Domain name and Busienss name?
Can we have different domain and Business name for website? I want to create real-estate website. I want to registered domain name ‘Nycityhomes.com’ and want to my business name (in logo as well) is ‘Sunny Associates’. Can we do that for local SEO?
Intermediate & Advanced SEO | | AlexanderWhite0 -
Duplicate Page Content / Titles Help
Hi guys, My SEOmoz crawl diagnostics throw up thousands of Dup Page Content / Title errors which are mostly from the forum attached to my website. In-particular it's the forum user's profiles that are causing the issue, below is a sample of the URLs that are being penalised: http://www.mywebsite.com/subfolder/myforum/pop_profile.asp?mode=display&id=1308 I thought that by adding - http://www.mywebsite.com/subfolder/myforum/pop_profile.asp to my robots.txt file under 'Ignore' would cause the bots to overlook the thousands of profile pages but the latest SEOmoz crawl still picks them up. My question is, how can I get the bots to ignore these profile pages (they don't contain any useful content) and how much will this be affecting my rankings (bearing in mind I have thousands of errors for dup content and dup page titles). Thanks guys Gareth
Intermediate & Advanced SEO | | gaz33420 -
Anchor text help
Hello, I am a small website designer in Mexico.. as you know it is hard to rank in these keywords My main competitors appear with (diseño web = web design) on google.com.mx Almost 80% of the anchor text from my links are (diseño web Mexico =web design Mexico) If I search (diseño web Mexico =web design) on google.com.mx I appear on first page. If I search (diseño web = web design) on google.com.mx I appear on page 3. My questions: Is this because my anchor text is diseño web Mexico? should i change it to (diseño web = web design)? Or is it because (diseño web = web design) is a harder key word to rank? this is my website http://bit.ly/eKyWvr Regards
Intermediate & Advanced SEO | | Pixelar0 -
Google +one button - help needed
I have installed Google plus button on my homepage. My GA report is being displayed like this - 7 total events were recorded Total Events Unique Events 7 2 Event action Total Events on 4 off 3 My questions are - 1 ) Is someone clicking on Google plus button considered an Event ? 2 ) What is meant by 2 Unique Events 3 ) Why does GA report shows on 4 and off 3
Intermediate & Advanced SEO | | seoug_20050