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 have FAQ schema code in home page?
Hi, can we have FAQ schema code in Home page ? we wrote some question and answer in drop down box on home page, and also add the schema code script to the head tag of page, but it does not work !,( other pages of our site show the FAQ in the SERP correctly) I want to know this problem is because its on Home Page ? or because its in Drop down style ? its the url of our site: http://payamgostar.com/
Intermediate & Advanced SEO | | allenwebmaster0 -
Content Help for Dealers
What type of content would anyone recommend writing for power sports dealers (ATV dealers, Motorcycle Dealers, Jet Ski Dealers, etc) or outdoor power equipment dealers (tractors, lawn mowers, etc) when they're website consists mainly of inventory pages? These dealers are trying to improve brand awareness, but creating content that answers searchers' questions/intent is tough and I want to make sure I am on the right track. I'm trying to create unique content. I am optimizing existing pages and then so far I've been writing brand pages, describing the brands, advertising that they carry this brand, creating links and call-to-actions to the inventory pages,etc. I want to first create authority and crawlable content for this brand. From there, I have been trying to create product category pages, describing the top products under that brand and working to creating product comparison content instead of simply describing it. Why Buy type of stuff, but that gets tricky to make unique. Any suggestions on unique content or better strategies versus just brand descriptions, product descriptions/comparisons, etc? I also want to make sure that creating multiple pages focused on one brand and an overall category isn't cannibalization of a topic. Obviously each page is slightly different and gradually going into more detail, but I want to make sure. Any recommendations on types of content or different strategies would be helpful! Also - I should mention that I am limited by the platform. I cannot create/utilize a blog page or anything like that. Thanks!
Intermediate & Advanced SEO | | Crichardson19900 -
Help... To Optimize Category Page or Not?
My question is about whether to optimize a category page or not, but it’s a rather odd situation. Here’s a bit of background to start. When we relaunched our site, about six months ago, we had primary, secondary, and tertiary categories created. A user could reach all three levels by clicking through the site. Then we decided instead of linking to the tertiary categories, that we’d turn them into filters which can be applied at the secondary level. Thus, there is not actually a direct link to the 3rd level categories on the site. An important side note, I did check and confirm they are still included in the sitemap file. My initial thoughts were to forget any further optimization of those 3rd level categories, but as it turns out we still have rankings for some of them. Now the question… Because some of these pages are ranking and are found in the sitemap, should I include them in my SEO plan to build up and optimize, or because they are no longer linked to directly on the site will they eventually fizzle out (and I shouldn’t do anything further). This is such a unique situation that I am really looking for some insight from the community. Thanks!
Intermediate & Advanced SEO | | M_D_Golden_Peak0 -
How can I remove my old sites URL from showing up in Google?
Hi everyone. We have had a new site up for over a year now. When I search site:sqlsentry.net the old url still shows up and while those pages are redirected to .com I'd like to get the .net URL's out of google forever. What is the best way I can go about that?
Intermediate & Advanced SEO | | Sika220 -
Hi I know this is cheeky but you are all so helpful on here!
hi, quick question, I've made a new instillation of wordpress at sussexchef.com/dev and I'm about to start building pages, obvoisly I'm going to move it to sussexchef.com when its all looking right. when I choose my page address links/ permalinks thingy, should I use new url names that don't already exist on the old site? or should I keep the old url names so I don't get loads of 404's, but include the "dev/" in the url name? Eg the old address sussexchef.com/home should I use sussexchef.com/dev/home or sussexchef.com/home-sussex-caterers while building the development site? I'm guessing the later my help out in google searches too? But if I use Dev in the url shurly I will have to go through almost 100 pages removing the dev/ and also changing all the links too? This would be days of work!
Intermediate & Advanced SEO | | SussexChef83
So confused! I'd really appreciate your help here. Ben0 -
Help with homepage SEO please
Hi I have been looking after this site www.kids-academy.co.uk for 3 weeks now. I spotted that links were a major problem with the site and started to strip out the black hat inbound links straight away. I have also been doing some onsite optimisation for the main areas I have been asked to focus on. This saw results within a week for the subpages which is great. however, the design of the site meant there were no landing pages for the categories and the menu is a permanent "fixture" called a megamenu. I have advised /landingpages were needed not only for the ease of the end user to find what they need but also for SEO. Now the issues I have are that due to the menu style, it sees every one of those links within the homepage - over 200 links! I am wondering if I should nofollow some of them, or get them to change the style of the menu as surely this is having a direct result on the homepage and landing pages just not being seen at all within Google (as normal - Bing and Yahoo love the site). There is a lot of work to do on this site, but I would have thought to have seen some movement on the homepage at least by now. Any help is much appreciated. (Please note, there are some duplicate pages on there at the moment as I amalgamated some of the pages together last night and need to redirect these but I am having issues with redirect loops so those are not a contributing factor as this is a recent change). Thanks
Intermediate & Advanced SEO | | LeanneSEO
Leanne0 -
Rankings Nose Diving Help Needed
Hey There SEO Community, I am trying to help these people: http://goo.gl/B1smo They once ranked in the top 10 for "lifewave" and "lifewave patches" but have disappeared. Any idea why and what I can do to help? Thanks!
Intermediate & Advanced SEO | | siteoptimized0 -
I dont know what happened?!? Help!
Up until yesturday I was mainly getting entrances to my site through www.moondoggieinc.com/dog-harness.php like 60-70 a day After yesterday, it's dropped to one or two! I haven't made any major changes to the site? I don't know what happened! I am starting to feel really discouraged and don't know what to do! I have no clue what my next move should be in trying to get this site working well in organic search. I feel lost now, PLEASE help! Any suggestions on what to do with http://www.moondoggieinc.com would be a great help! I feel so lost! THANKS! Kristy O
Intermediate & Advanced SEO | | KristyO0