I've tried all sorts of ways. I am having trouble redirecting the root .htaccess file to a subdirectory/public file.
Currently, the root redirects to the folder but the path of file shows up in the url.
For example:
website.com/flarum/public should be website.com
...
public_html
-- .htaccess // below
-- flarum
---- public
------.htaccess //default flarum's htaccess
.htaccess
RewriteEngine On
RewriteRule ^$ /flarum/public/ [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/flarum/public/
RewriteRule ^(.*)$ /flarum/public/$1
right now it is showing, website.com/flarum/public where it should be website.com
Related
Im trying to make a .htaccess file that blocks every folders and file with the exepction of the folder public, the file index.php, the file ajax.php, img, css and js. It should also redirect you to www.domain.com/index.php no matter what you type in the url. Almost everything is working but the ajax.php file is still blocked so my javascript files cant access it. Any suggestions?
My index.php is placed in the folder public, all other php files is placed in a folder named php, js, css and so on but they are not inside public. its like this /root/public and /root/php and so on. The .htaccess file is placed in /root/
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ public/index.php?_url=$1 [QSA,L]
RewriteCond %{REQUEST_URI} !^/(?:public/|index\.php$|ajax\.php$|.+\.(?:jpe?g|gif|png|ico|tiff|css|js)$) [NC]
RewriteRule . - [F]
Have it this way:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/(?:public/|(?:index|ajax)\.php$|.+\.(?:jpe?g|gif|png|ico|tiff|css|js)$) [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ public/index.php?_url=$1 [QSA,L]
I have the following domain pmartins.pt, and I added the following sub-domain euromilhoes.pmartins.pt . I needed to point the sub-domain to pmartins.pt/euromilhoes/public and I used the following in the .htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ /euromilhoes/public [L]
This works fine but I would like to hide the public folder from the URL. So now I have this http://pmartins.pt/euromilhoes/public/, and I would like it to be http://pmartins.pt/euromilhoes/
Can I do it via .htaccess?
To redirect from root to subfolder ,you can use
RewriteEngine on
#exclude existent dirs
RewriteCond %{REQUEST_FILENAME} !-d
#exclude existent files
RewriteCond %{REQUEST_FILENAME} !-f
# rewrite any other request to /publice
RewriteRule ^(.+)$ /public/$1 [NC,L]
if my site is domain.com and if i go to domain.com/1 and the folder 1 dont exist can i redirect via .htacces to domain2.com/1
if file or folder exist i like to show that file or folder but if not exist then to redirect to new domain
example: if file.html dont exist in my server then
example.com/file.html redirect to newdomain.com/file.html
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ newdomain.com/$1
You need to include the http:// bit:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://newdomain.com/$1 [L,R]
otherwise, mod_rewrite will interpret that as a URL or file path and attempt to look for a directory called "newdomain.com". If you want the redirect to be permanent, change the R flag to R=301.
I am having issues with htaccess redirections. Following is the issues I am having.
The root folder to which the main domain actually points has the following folder: "example"
example.com is actually internally linked to the path "root/example/" rather than "root/". This is done using the following htaccess code
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteCond %{REQUEST_URI} !^/example/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /example/$1
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteRule ^(/)?$ example/index.html [L]
The folder "exmaple" has the following subfolders: newexample, newexample_beta
If I go to the URL "example.com/newexample", the URL needs to be internally linked to "root/example/newexample". But the URL redirects me to "example.com/example/newexample/"
could you please let me know what needs to be done
I can't seem to figure this out, I have a directory structure in my root folder like '/state/page--city'. In my htaccess file i redirect all requests that are not directories or files in my root folder to a page.php. So what I would want is to remove the '/state' part from the URL when the users access 'http://example.com/state/page--city/' so that the URL looks like 'http://example.com/page--city/'. Any ideas? Thnx.
.htaccess file:
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* page.php?&[|]v1||%{REQUEST_URI}[|]v2||-[|]v3||%{HTTP_HOST}[|]v4||%{REQUEST_FILENAME}[|]v5||EOL[~|~]= [QSA,L]