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
-
Help with structure for optimizing Photography Website SEO
Hey guys , I am building a photography website and currently I have it setup the following way for my image galleries : https://ricfrancophotography.com/portfolio/norway-landscape-photography/#!gallery6618-6577 This provides me with an individual link for each of the images in my photography gallery but as a gallery these have obviously no content and I figured the best way would be to add the images I want to work my SEO for to individual blog posts . So here is what I did so far : - Added a link to the caption of each image inside the lightbox that is linking to the individual blog post - In order to not break the navigation I made the post with the content for each image open in a modal popup (it changes the link in the top bar but once closed it goes back to the gallery) . - I made the image inside the post link back to the fullsize image in the lightbox gallery when clicked instead of linking to the .jpg in wp-content/uploads. Now, I have some questions regarding whether this is a good practice in terms of SEO and if the fact of having duplicate images or this structure is going to hurt my SEO any way . Although both images are in different urls they ultimately link to each other this way : Blog Image --> Gallery Image url --> wp-content/uploads/file.jpg Is there a better approach for this ? Thanks
Intermediate & Advanced SEO | | ricfranco0 -
URL no longer ranks after redesign, everything was done by the book. Can someone plz help?
Hey Mozzers, After a redesign of our site we have a huge problem with 1 particular URL. We can't understand what is wrong with it. Our site was redesigned about 3 weeks ago everything was done to make sure the process was smooth. Content on the new url was exactly the same as before, title tags and meta descriptions were copy pasted, 301 redirects were set up. Our site has 47 pages and all other pages are still ranking the same way as they used to before the update but this one url has just dropped from serps or once a while is appearing on 2nd, 3rd pages. URL in question is: https://dcacar.com/dulles-limo-service/ We are a MOZ pro client and have the data on where this url was ranking prior to the update. Keywords it ranked for #1position on page one- some examples ( car service to dulles, car service to iad, dulles airport limo service) and many more. The only thing that has changed was the url the old url was https://www.dcacar.com/dulles-limo-service.html After the new design we got rid of the ".html" on all our urls, the funny thing is that all our 46 urls were updated the same way but only this url is experiencing this problem. Google search console shows that url is indexed and on Google but sometimes it does not show up on serps. Can anyone please help? 20% of our business comes from this url and we are loosing real money everyday and I can't figure out was is wrong with it. Thanks all, Davit
Intermediate & Advanced SEO | | Davit19850 -
Help with 404 pages
Hello everyone, A few days back, we have permanently removed 3 main categories from our E-commerce website and because of that our more than 50k URLs are showing 404 error (according to Google Search Console). What are the good practices to handle such extensively 404 pages? Please help!!
Intermediate & Advanced SEO | | Obbserv0 -
How many outbound links, we can add to our blog content?
We can add any number of links? from authority websites? Like - http://packforcity.com/save-money-on-a-trip-to-disneyland/ http://packforcity.com/how-to-save-money-when-traveling-to-disneyland-part-2/ http://packforcity.com/new-york-city-top-faqs-for-travels/ http://packforcity.com/what-to-wear-in-kyoto-in-february/
Intermediate & Advanced SEO | | bondhoward0 -
Can you canonical your homepage to a different URL on the same domain?
I would like to know if it is acceptable (or even possible from Google's standpoint) to canonical your homepage to a different URL on the same domain? For example, my homepage is www.grasscare.com (it's not) and I've built links to that page for years for terms like "grass seed" and "buy grass seed" because all I sold in the past was grass seed. If I then decide I want to sell both grass seed and sod, can I canonical my homepage (grasscare.com) to a new URL www.grasscare.com/grasss-seed.html to preserve the link value I've built up for "grass seed"?The new homepage would turn into a doorway page of sorts, forcing users to select either grass seed or sod before going further. Whatever content there is on the new homepage about grass seed would also be present on grasscare.com/grass-seed.html, though it would only be a small amount of content. Can a canonical be used to point the homepage to this new page and also, will this canonical pass all of the link value and ranking signals it help in the past to the new URL? Thank you in advance for any help or insight.
Intermediate & Advanced SEO | | andrewv0 -
Canonicals for product pages - confused, anyone help?
I have an ecommerce website (built using Magento), and have just had the functionality extended to allow me to define my own canonical URLs. Currently the URLs are www. domainname.com/product-name.html but I can now change this to www.domainname. com/product-category/product-name.html. I was led to believe that this would be good for SEO. However, I have since had conflicting advice - it's been suggested that any links across the website that link to domain/category/sub-category/product will pass weight and authority through to the specified canonical anyway. Plus longer URLs are generally worse... I'm confused. Is it worth changing them? If so, would it be a bad thing to change all 700 canonical URLs at once?
Intermediate & Advanced SEO | | Coraltoes770 -
Doing SEO for a Classifieds Website and need help
Hey All! I'm going to be doing SEO for a classifieds website (cars only). But I'm struggling to dream up an effective strategy. They have a reasonably popular blog that I could definitely use to publish content for link bait, and some opportunities for guest blogging. But in terms of straight up link building (think craigslist), I'm really at a loss as to where to start. If anyone has any experience working with Classifieds websites or can recommend any strategies that you think will work I'm all ears! Really appreciate any help that anyone has to offer! Cheers 🙂
Intermediate & Advanced SEO | | CD_20160 -
Please help with some content ideas
I was reading this post http://www.clambr.com/link-building-tools/ about how he had basically outreached to experts in the field and each one had shared this post with their followers. I am wondering how this could translate to our small business marketing and design blog I am really struggling for content ideas that will work in regards to popularity and link building.
Intermediate & Advanced SEO | | BobAnderson0