Page is a not externally linkable
- Code, Content, and Presentation
-- Apache Web Server
---- Issues running CMS in subfolder


Patrick_Taylor - 6:36 pm on Jan 28, 2013 (gmt 0)


It's me again and I am still struggling with this after some time.

RewriteRule ^laplume/$ /laplume/cms/index.php [L]

g1smd: If you requested example.com/laplume/ AND there's a file inside the server at /laplume/cms/index.php and the script is able to detect that /laplume/ was requested and it has some content to deliver for that request, then it should work.


I'm afraid it just doesn't (although I cannot see why). A request for /laplume/ results in the following error: "You don't have permission to access /laplume/ on this server. Additionally, a 404 Not Found error ..." but when I go to /laplume/cms/index.php I see the page.

The other thing that baffles me...

# Redirect GET /cms/string.php HTTP/1.1 to /string (the link)
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /cms/([A-Za-z0-9_-]+)\.php\ HTTP/
RewriteRule ^cms/([A-Za-z0-9_-]+)\.php$ /$1 [R=301,L]

RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^$ /cms/index.php [L]

RewriteCond %{REQUEST_URI} !^/index$
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([A-Za-z0-9_-]+)\ HTTP/
RewriteRule ^([A-Za-z0-9_-]+)$ /cms/$1.php [L]


The first rule redirects /laplume/cms/anypage.php to the second or third rules (depending on whether the page is "index" or not). It prevents /laplume/cms/anypage.php being viewable (duplicate) and the user sees /laplume/anypage in the address bar and the content. This works in the root. However, for the subfolder /laplume/ my .htaccess has this:

# Redirect GET /laplume/cms/string.php HTTP/1.1 to /laplume/string (the link)
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /laplume/cms/([A-Za-z0-9_-]+)\.php\ HTTP/
RewriteRule ^laplume/cms/([A-Za-z0-9_-]+)\.php$ /laplume/$1 [R=301,L]

RewriteCond %{REQUEST_URI} ^/laplume/$
RewriteRule ^$ /laplume/cms/index.php [L]

RewriteCond %{REQUEST_URI} !^/laplume/index$
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /laplume/([A-Za-z0-9_-]+)\ HTTP/
RewriteRule ^([A-Za-z0-9_-]+)$ /laplume/cms/$1.php [L]


Nothing happens. It seems the same principle as the root example should apply, the only difference being the addition of /laplume/. It seems not. The whole thing is becoming a confusing mess.


Thread source:: http://www.webmasterworld.com/apache/4533901.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com