Hi,
I have an issue, i am new to using .htaccess files and have an issue.
Basically i am working on this site:
{snip}
You will see my file structure, if you click on “view” you will be taken to my homepage.
Now in my .htaccess file i need to make it so when you visit this page:
{snip}
It takes me to the homepage…
I thought the following reWrite rule would work but it doesn’t:
RewriteRule ^$ view/index.php [L]
Can anyone help?
Thanks
Hey,
Well i didn’t really change much, i was getting a 500 internal server error, so i had to change the file permissions, and for this i simply contacted the hosting provider as i was doing this website on a freelance basis for a client.
Thought that was the best thing to do.
Thanks
Billy,
I’m glad that you got it sorted. If you would be so kind as to post the changes you made, it might help others in the same situation.
Regards,
DK
Thanks thats worked with a bit of work 
Thanks again
Billy,
NEVER post your phpinfo page online! There’s too much information in there for hackers!
What you need to do FIRST is create an .htaccess file in your webspace’s home directory (DocumentRoot) which is your ~{snip}/ directory. Actually, that’s the first level subdirectory because you are not a VirtualHost on this server but you shouldn’t have access to the DocumentRoot of the www.prima.cse.salford.ac.uk subdomain (on the 8080 port!?!).
In that .htaccess file, use the following code:
# Turn OFF the directory listings!
Options -Indexes
# create a preferred file which will be served on lack of a filename in the http request
DirectoryIndex index.php index.html
# Assuming that mod_rewrite is enabled
RewriteEngine on
# check for directory in {REQUEST_URI}
RewriteCond %{REQUEST_URI} !^/?(admin|library|model|nbproject|view)/
# if no directory, redirect to the view subdirectory
RewriteRule .? view%{REQUEST_URI} [L]
TWO WARNINGS:
-
If the above gives you 500 errors from your server, you do not have mod_rewrite enabled. Comment out the mod_rewrite part immediately!
-
The relative links within your view directory should be relative to the DocumentRoot, NOT view (because the browsers will “see” that they are in your DocumentRoot, NOT DocumentRoot/view.
You may want to use the test in my signature’s tutorial to see whether you have mod_rewrite enabled rather than suffer 500’s.
Regards,
DK
That rule looks fine to me.
Could you post the complete .htaccess ?
Edit:
Unless your host is running Apache 1.x, in which case it should be ^/$ instead of ^$
Both the directory index and phpinfo() show Apache 2.2.8 so that was okay IF in DocumentRoot (of a VirtualHost. It’s not so a leading / should be used.