Results 1 to 2 of 2
Thread: .htaccess rewrite rule
Jun 10, 2009, 16:35 #1
- Join Date
- Feb 2009
- Tampa, FL
- 0 Post(s)
- 0 Thread(s)
.htaccess rewrite rule
I'm in need of a rewrite rule that I am not sure is possible.
Here's the scoop:
My blog currently sits in the root of my domain (http://www.adminaddict.net).
We plan to move the blog to its own directory (/blog) and replace the root with an index/homepage with links to our various services and resources.
Doing this would naturally cause all links to our blog articles (in the formation of adminaddict.net/123-article-title) to become broken.
If we implemented a rewrite rule where all attempts of accessing adminaddict.net/xyz are redirected to adminaddict.net/blog/xyz then our homepage would never be accessible.
So here's what I want to do (if it's even possible):
"If the URL is in the format of adminaddict.net/(a-number)-(text), then redirect to /blog/(a-number)-(text). Otherwise (for example, if the URL is /forum), don't redirect."
So here is how it should be:
adminaddict.net/ -> not redirected
adminaddict.net/forum/xyz -> not redirected
adminaddict.net/directory -> not redirected
adminaddict.net/123-blog-article -> adminaddict.net/blog/123-blog-article
Is this possible?
Jun 10, 2009, 17:49 #2
- Join Date
- Feb 2002
- 19 Post(s)
- 2 Thread(s)
On the surface, this appears to be an easy problem with two possible solutions:
1. Merely check whether the directory/file exists before redirecting
2. Use the apparent fact that your blog URIs do not have a dot character in them to redirect extensionless URIs to the blog subdirectory.
If you need help on either, please check the tutorial linked in my signature then show your code here. I'm happy to show how to correct minor errors and provide explanations as to why they are necessary.