Rewrite list of words to index.php - mod-rewrite

I need to rewrite a few urls to the same page. Is there an easy way of rewriteing the following urls to index.php:
www.test.com/miami.html
www.test.com/chicago.html
www.test.com/boston.html
and rewrite them to
www.test.com/index.php
Thank you

Assuming this is going in your .htaccess, if you're wanting an external rewrite (i.e. changing the browser URL):
RewriteEngine On
RewriteBase /
RewriteRule ^(miami|chicago|boston)\.html$ index.php [R,NC,L]
If you're wanting an internal rewrite:
RewriteEngine On
RewriteRule ^(miami|chicago|boston)\.html$ index.php [NC,L]
These assume you have the rewrite module enabled in the main config:
LoadModule rewrite_module modules/mod_rewrite.so

Related

How Do I use mod_rewrite

I have a url with:
http://example.com/index.php
I want it to be
/index
I will need to use mod_rewrite to make a virtual folder for a PHP or HTML file with .htaccess.
RewriteEngine on
RewriteRule ^index.php$ index/
This is not working
Any answers?
I think you want reverse rule:
RewriteEngine on
RewriteRule ^index/?$ index.php

mod_rewrite how to transfer root to specific file

i am using smarty framework and the urls are dynamic build with master-layout index file.
i want to make a mod_rewrite rule to transfer the url
www.mysite.com to /mysiteSubfolder/member/index.php
No redirect, just to map the urls to those calls, for the sake of SEO friendly url.
www.mysite.com/home.html works as desired but the root url not working.
i tried the following but it just stays on root url's index file root/index.php
here is my current .htacces code
Options -Multiviews
Options -Indexes
RewriteEngine On
RewriteRule ^$ /mysiteSubfolder/client/index.php (not working)
RewriteRule ^home.html$ /mysiteSubfolder/client/index.php (working)
Your root .htaccess, ie, /.htaccess, but not in /mysiteSubfolder/client/.htaccess, should be like this (TESTED on Debian/Apache2):
Options -Multiviews
Options -Indexes
RewriteEngine On
RewriteRule ^$ /mysiteSubfolder/client/index.php [L]
RewriteRule ^home.html$ /mysiteSubfolder/client/index.php [L]

Escaped Fragment Redirect htaccess

my website (thedutchtilt.com) employs AJAX.
Now I know that whenever Google tries to crawl a page, e.g. #!stories/component_74511, it will turn that url into thedutchtilt.com/?_escaped_fragment_=stories/component_74511 .
My question is, how do I format a htaccess redirect so that the aforementioned site will map to the other one?
I've tried
RewriteCond %{QUERY_STRING} ^_escaped_fragment_=stories/component_74511
RewriteRule ^$ http://www.thedutchtilt.com/full.html? [R=302,L]
but trying this just gives http://thedutchtilt.com/?_escaped_fragment_=stories/component_74511, which is my homepage.
I'm really confused now, and nothing seems to be working (sigh).
Kartik
Current .htaccess:
RewriteEngine on
RewriteOptions inherit
# Use PHP5 Single php.ini as default
AddHandler application/x-httpd-php5s .php
RedirectMatch ^/$ /index.html
RewriteCond %{QUERY_STRING} ^_escaped_fragment_=stories/component_74511
RewriteRule ^$ thedutchtilt.com/full.html? [R=302,L]
Thanks for providing .htaccess code. Problem is your this RedirectMatch line:
RedirectMatch ^/$ /index.html
Comment it out and try again. index.html should be loaded as default using this DirectoryIndex directive:
DirectoryIndex index.html

Mod rewrite apache - rewriting only base url

I'd like to rewrite
www.site.com/a/b/?param1=one&param2=two
in
www.site.com/c/d/e/?param1=one&param2=two.
Where www.site.com/a/b does not exists. I tried with
RewriteEngine on
Options +FollowSymLinks
RewriteRule ^a/b/(.*)$ www.site.com/c/d/e/$1 [QSA,L]
What's wrong with it?
Try this one:
RewriteEngine on
Options +FollowSymLinks
RewriteRule ^/a/b/(.*)$ /c/d/e/$1 [QSA,L]
There is no need for adding the incompleate domain. If you want that the users visit a second domain you have to add the R option and the protocol. For a redirect to a second domain try this:
RewriteRule ^/a/b/(.*)$ http://www.site.com/c/d/e/$1 [R,QSA,L]

htaccess redirect to subfolder with same path attached?

How can I go about redirecting my old URLs which would have been: http:// blah.com/some/post/name
to the new URLs which would be: http:// blah.com/new/some/post/name
Is this even possible?
I don't want to simply redirect any requests for the blah.com domain to blah.com/new
I want to make sure the subpath is still attached to the redirect
it should be possible.
Try to put this in your .htaccess file:
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/some\/?
RewriteRule (.*) /new/$1 [R=301]
</IfModule>
Try it out and let me know - I haven't had time to test it very thoroughly.

Resources