LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 04-02-2010, 07:59 AM   #1
skylimit123
LQ Newbie
 
Registered: Nov 2008
Posts: 21

Rep: Reputation: 15
.htaccess rewrite problem


Dear all

Is there a way that on linux web server running apache, i make configuration for a web site, so whenever somebody clicks a link on a website that points to .xy domain it redirects him to same link but on .ab domain.

for example there are links on website that are
www.test.xy/index.php?page=test1

it has to be redirected to www.test.ab/index.php?page=test1

it would be nice that rule for redirection is applied to sub folders also


tnx in advance
 
Old 04-02-2010, 08:15 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Hi,

You can use a .htaccess in the docroot of your server, so rewriting happens for subdirs also:
Code:
RewriteEngine on

RewriteCond %{HTTP_HOST} ^www.test.xy$
RewriteRule (.*) http://www.test.ab/$1
Regards
 
Old 04-02-2010, 08:55 AM   #3
skylimit123
LQ Newbie
 
Registered: Nov 2008
Posts: 21

Original Poster
Rep: Reputation: 15
thnx bathory for fast reply.. i was hoping for some .htaccess solution...
but this one you just sent is not working.. domain suffix still doesn't change
 
Old 04-02-2010, 09:23 AM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Are you sure that apache uses .htaccess?
You need "AllowOverride All" to use .htaccess and "Options FollowSymLinks" for mod_rewrite.

You can enable mod_rewrite logging to find out what happens

Also you can check your logs for 30x access code:
Quote:
x.x.x.x - - [02/Apr/2010:17:13:19 +0300] "GET / HTTP/1.0" 302 206
 
Old 04-02-2010, 10:53 AM   #5
skylimit123
LQ Newbie
 
Registered: Nov 2008
Posts: 21

Original Poster
Rep: Reputation: 15
on the specific virtual hosts there are directives under <Directory>...</Directory> AllowOverride and Options FollowSymLinks
and .htaccess is working (in different way but it is working) for another virtual host.
when I insert RewriteLog nothing is logged .
About access codes, I can only find 304, but it is there for a longer period of time.
 
Old 04-02-2010, 11:11 AM   #6
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
If nothing is logged, then mod_rewrite does not work, either because the .htaccess is not read by apache, or the RewriteCond does not meet.
You can use a simple rewrite to see if it works:
Code:
RewriteEngine on

RewriteRule whatever.html some.html
Replace whatever.html and some.html with existing pages and test if apache redirects whatever.html to some.html

You can also put the rewrite directive inside the <Directory ...>..</Directory> of your vhost.
 
Old 04-02-2010, 11:42 AM   #7
bnettles
LQ Newbie
 
Registered: Jul 2008
Posts: 4

Rep: Reputation: 0
.htaccess rewrite problem

This post may help clarify what else you need to do to get url-rewrite working on how to properly fix the http.conf file. Others have already said to do this but it is not too clear unless you see it.

http://trisummit.net/2010/03/27/stil...write-to-work/
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
apache rewrite F problem xiutuo Linux - Server 3 09-10-2009 10:48 PM
htaccess 301 rewrite BillKat Linux - Server 2 04-07-2009 12:54 PM
Mod Rewrite Problem mpapet Linux - Server 0 03-30-2008 04:51 PM
Apache2 mod vhost_alias - problems with .htaccess mod rewrite d_t_baker Linux - Server 1 08-16-2007 07:32 PM
Problem with Apache rewrite griffey Linux - Software 1 08-10-2007 06:19 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 08:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration