Apache Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsSystem AdministrationApache Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 22nd, 2012, 09:21 AM
lokisapocalypse lokisapocalypse is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2005
Posts: 623 lokisapocalypse User rank is First Lieutenant (10000 - 20000 Reputation Level)lokisapocalypse User rank is First Lieutenant (10000 - 20000 Reputation Level)lokisapocalypse User rank is First Lieutenant (10000 - 20000 Reputation Level)lokisapocalypse User rank is First Lieutenant (10000 - 20000 Reputation Level)lokisapocalypse User rank is First Lieutenant (10000 - 20000 Reputation Level)lokisapocalypse User rank is First Lieutenant (10000 - 20000 Reputation Level)lokisapocalypse User rank is First Lieutenant (10000 - 20000 Reputation Level)lokisapocalypse User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 5 Days 22 h 58 m 20 sec
Reputation Power: 144
mod_rewrite - Load from a subdirectory

Hi all,

I'm having trouble with a mod_rewrite case. I have the following .htaccess file in the main web directory:

Code:
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /myproject
  RewriteRule ^$ views/    [L]
  RewriteRule (.*) views/$1 [L]
</IfModule>


What I'm trying to do, is when a user requests a page of the form http://www.mysite.com/myproject/whatever, it loads http://www.mysite.com/myproject/views/whatever.

But when I try the code presented above, I get a 404.

So what am I doing incorrectly?

Reply With Quote
  #2  
Old January 24th, 2012, 12:15 PM
lokisapocalypse lokisapocalypse is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2005
Posts: 623 lokisapocalypse User rank is First Lieutenant (10000 - 20000 Reputation Level)lokisapocalypse User rank is First Lieutenant (10000 - 20000 Reputation Level)lokisapocalypse User rank is First Lieutenant (10000 - 20000 Reputation Level)lokisapocalypse User rank is First Lieutenant (10000 - 20000 Reputation Level)lokisapocalypse User rank is First Lieutenant (10000 - 20000 Reputation Level)lokisapocalypse User rank is First Lieutenant (10000 - 20000 Reputation Level)lokisapocalypse User rank is First Lieutenant (10000 - 20000 Reputation Level)lokisapocalypse User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 5 Days 22 h 58 m 20 sec
Reputation Power: 144
Any ideas on this one?

Reply With Quote
  #3  
Old January 24th, 2012, 12:37 PM
Nilpo's Avatar
Nilpo Nilpo is offline
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2004
Location: New Springfield, OH
Posts: 863 Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)  Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 5 Days 16 h 50 m 17 sec
Reputation Power: 1185
Send a message via ICQ to Nilpo Send a message via AIM to Nilpo Send a message via MSN to Nilpo Send a message via Yahoo to Nilpo Send a message via Google Talk to Nilpo Send a message via Skype to Nilpo Send a message via XFire to Nilpo
Facebook MySpace Orkut
This...

RewriteRule ^$ views/

isn't matching anything. ^ = start of value, $ = end of value. So your regular expression is matching "nothing" quite literally.

Try something like this...
Code:
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{REQUEST_URI} ^/myproject [NC]
  RewriteRule ^/myproject/(.*)$ /myproject/views/$1 [L]
</IfModule>
This is saying, if the request URI begins with /myproject, it should match the end portion of the URI and rewrite it.
__________________
Don't like me? Click it.

Scripting problems? Windows questions? Ask the Windows Guru!

Stay up to date with all of my latest content. Follow me on Twitter!

Help us help you! Post your exact error message with these easy tips!

Last edited by Nilpo : January 24th, 2012 at 12:40 PM.

Reply With Quote
  #4  
Old January 24th, 2012, 06:29 PM
lokisapocalypse lokisapocalypse is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2005
Posts: 623 lokisapocalypse User rank is First Lieutenant (10000 - 20000 Reputation Level)lokisapocalypse User rank is First Lieutenant (10000 - 20000 Reputation Level)lokisapocalypse User rank is First Lieutenant (10000 - 20000 Reputation Level)lokisapocalypse User rank is First Lieutenant (10000 - 20000 Reputation Level)lokisapocalypse User rank is First Lieutenant (10000 - 20000 Reputation Level)lokisapocalypse User rank is First Lieutenant (10000 - 20000 Reputation Level)lokisapocalypse User rank is First Lieutenant (10000 - 20000 Reputation Level)lokisapocalypse User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 5 Days 22 h 58 m 20 sec
Reputation Power: 144
Thanks for the tip Nilpo. I just confirmed with the Unix team that our webservers are configured to ignore .htaccess files. That's why my really simple examples I was trying didn't work either. Occum's razor and all.

Reply With Quote
  #5  
Old January 24th, 2012, 06:54 PM
Nilpo's Avatar
Nilpo Nilpo is offline
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2004
Location: New Springfield, OH
Posts: 863 Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)  Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 5 Days 16 h 50 m 17 sec
Reputation Power: 1185
Send a message via ICQ to Nilpo Send a message via AIM to Nilpo Send a message via MSN to Nilpo Send a message via Yahoo to Nilpo Send a message via Google Talk to Nilpo Send a message via Skype to Nilpo Send a message via XFire to Nilpo
Facebook MySpace Orkut
Quote:
Originally Posted by lokisapocalypse
Thanks for the tip Nilpo. I just confirmed with the Unix team that our webservers are configured to ignore .htaccess files.
Well I guess that would certainly explain it too.

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationApache Development > mod_rewrite - Load from a subdirectory

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap