The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 17, 2019, 11:55:20 PM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: htaccess, redirect / to a specific page  (Read 3169 times)
nutballs
Administrator
Lifer
*****
Offline Offline

Posts: 5627


Back in my day we had 9 planets


View Profile
« on: March 14, 2008, 09:39:02 PM »

i have tried a bunch of things that should work, but dont.

how do i redirect requests that come in without a named document such as:
http://www.somedomain.com/

that trailing slash. I want anything that comes into the root of the domain to get redirected to a specific page.

i tried
RewriteRule ^\/$ /targetpage.php [L,R]

but it no worky.
Logged

I could eat a bowl of Alphabet Soup and shit a better argument than that.
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #1 on: March 15, 2008, 09:54:39 AM »

It's funny you post this... I had some Apache stuff I was after yesterday and had trouble with mod_rewrite & .htaccess all day as well - I put the exact same code into the httpd.conf file and it worked perfectly. So I am thinking there is something I don't know about the way that mod_rewrite executes in .htaccess that is different from the way it behaves when in the .conf file...

I'll be looking at that today and will post as I know more. Your instruction looks fine, you're on the right track... more as I grind it out.

/p
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
Bompa
Administrator
Lifer
*****
Offline Offline

Posts: 564


Where does this show?


View Profile
« Reply #2 on: March 15, 2008, 10:27:25 AM »

i have tried a bunch of things that should work, but dont.

how do i redirect requests that come in without a named document such as:
http://www.somedomain.com/

that trailing slash. I want anything that comes into the root of the domain to get redirected to a specific page.

i tried
RewriteRule ^\/$ /targetpage.php [L,R]

but it no worky.

Is that all you tried?  What happened with that code?

I use this on several domains:

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_URI} !images
RewriteRule (.*) homepage.cgi [L]

The Cond is so gif in my images folder do not get rewritten.

If I used the R flag, it would wind up in a loop.

On some file systems, nothing works without the correct RewriteBase.

Also, the / does not need to be escaped cuz the regex is not using /'s as delimiters.


« Last Edit: March 15, 2008, 11:00:31 AM by Bompa » Logged

"The most beautiful and profound emotion we can experience is the sensation of the mystical..." - Albert Einstein
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #3 on: March 15, 2008, 11:08:15 AM »

Two interesting points...

* I don't use the R flag, so I don't know its behavior
* I notice no forward slash in the front the conversion... I wonder if by adding a forward slash in the .htaccess file if that causes a loop as well...
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
nutballs
Administrator
Lifer
*****
Offline Offline

Posts: 5627


Back in my day we had 9 planets


View Profile
« Reply #4 on: March 15, 2008, 12:11:14 PM »

bomps, thanks for the feedback, it sparked the solution for me. Yea i tried a bunch of things, i just meant to post 1 to show the "area" I had been looking in.

This worked:
RewriteRule ^$ /somepage.php [L,NC]

yeay team.
Logged

I could eat a bowl of Alphabet Soup and shit a better argument than that.
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!