Reputation: 23563
The following in my htacess file works to remove add a # character to the url. So mysite.com/page2 becomes mysite.com/#page2
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ /#$1 [L,NE,R]
This works fine however my site is actually going to be in a folder in the web root, not the root itself. So I need something like existingsite.com/mysite/page2 to redirect to existingsite.com/mysite/#page2
Ideally I would like to have this controlled by the htaccess thats within my site folder so that I dont need to change the htaccess file for the main site. Ive moved the site (including the htaccess file) into a folder in the web root but now its not working like before (when it was in the web root).
Upvotes: 0
Views: 73
Reputation: 23563
This works when placed in the htaccess file in the folder of the new site (not the web root).
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ /santa7/#$1 [L,NE,R]
Upvotes: 0
Reputation: 6720
Use rewritebase:
RewriteBase /mysite/
And your existing rewrites:
RewriteEngine On
RewriteBase /mysite/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ /#$1 [L,NE,R]
Also see: How does RewriteBase work in .htaccess
Upvotes: 1