homepage Welcome to WebmasterWorld Guest from 54.205.254.108
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
.htaccess prevents subdirectory access
thanili




msg:4644456
 12:24 pm on Feb 12, 2014 (gmt 0)

Guys,

i have a Joomla site running under an apache and i am using .htaccess for URL rewritting.

I have also several old sub-sites listed in sub-directories under the root like:

public_html/XXXX/site1
public_html/XXXX/site2
public_html/XXXX/site3

and also:

public_html/site4

the first 3 (site1,site2,site3) has index pages named: index.html

but the last 1 (site4) has an index page named: ProFI.html

All first 3 are working all right but the 4th one returns a:

403 error - You don't have permission to access / on this server

I do not known if index page naming is responsible and i am trying to redirect any requests for:

http://www.example.com/site4/ to http://www.example.com/site4/ProFI.html

URL 'http://www.example.com/site4/ProFI.html'

is working...

Any ideas on how to setup? I am new to .htaccess patterns!

[edited by: phranque at 6:37 pm (utc) on Feb 12, 2014]
[edit reason] Please Use example.com [webmasterworld.com] [/edit]

 

thanili




msg:4644457
 12:35 pm on Feb 12, 2014 (gmt 0)

I am also attaching some parts from my .htaccess file:

########## Begin - RewriteEngine enabled
RewriteEngine On
########## End - RewriteEngine enabled

# RewriteBase /

########## Begin - Redirect non-www to www
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
## If the above throws an HTTP 500 error, swap [R=301,L] with [R,L]
########## End - Redirect non-www to www

########## Begin - Joomla! core SEF Section
#
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
#
# If the requested path and file is not /index.php and the request
# has not already been internally rewritten to the index.php script
RewriteCond %{REQUEST_URI} !^/index\.php
# and the request is for the site root, or for an extensionless URL,
# or the requested URL ends with one of the listed extensions
RewriteCond %{REQUEST_URI} /component/|(/[^.]*|\.(php|html?|feed|pdf|vcf|raw|ini|zip|json|file))$ [NC]
# and the requested path and file doesn't directly match a physical file
RewriteCond %{REQUEST_FILENAME} !-f
# and the requested path doesn't directly match a physical folder
RewriteCond %{REQUEST_FILENAME} !-d
# internally rewrite the request to the index.php script
RewriteRule .* index.php [L]
#
########## End - Joomla! core SEF Section

lucy24




msg:4644568
 9:53 pm on Feb 12, 2014 (gmt 0)

All first 3 are working all right but the 4th one returns a:

403 error - You don't have permission to access / on this server

I do not known if index page naming is responsible and i am trying to redirect any requests for:

http://www.example.com/site4/ to http://www.example.com/site4/ProFI.html

If ProFI.html is functionally the index page of that directory, you have to say so. You can either make an expanded list in your primary htaccess

DirectoryIndex index.html index.php ProFI.html

or put the supplementary bit in its own little htaccess within that one directory:

DirectoryIndex ProFI.html

:: detour to re-check something ::

OK, that makes sense. DirectoryIndex directives within the same context (here that means "in the same htaccess file") are cumulative. So a new directive in a new htaccess overrides anything earlier. I'd go with the second one, though it doesn't make a huge difference.

But really, why not just rename the file? You'd want a redirect in any case:

RewriteRule ^blahblah/ProFI\.html http://www.example.com/blahblah/ [R=301,L]

Since it's only one specific file, you don't need to capture anything. Spell out the exact name on each side of the rule.

########## End - RewriteEngine enabled

Huh what?

########## Begin - Redirect non-www to www
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ [%{HTTP_HOST}...] [R=301,L]
## If the above throws an HTTP 500 error, swap [R=301,L] with [R,L]

This is, I take it, the part of joomla's htaccess that g1smd wasn't allowed to lay hands on. If you've got a single site using this htaccess file, it should be

RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved