I have 2 folder on my FTP.
www/
www/test/
So..
example.com
example.com/test
In folder test
is htaccess with
RewriteRule booking\.php booking.php
but when i click on link
<a href"/booking">Link</a>
Redirect me to
https://example.com/booking
but I need redirect to
https://example.com/test/booking
Can you help me please?
I know how to make with link
<a href="/test/booking">
but I need make this with htaccess.
Use The rewrite rule that uses ^$ because this represents the root and rewrite that to your folder /test , like this:
Use this method:
RewriteEngine On
RewriteRule ^$ /test [L]
Or this method:
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/test
RewriteRule ^(.*)$ /test/$1 [NC,L]
Related
I have this URL:
http://www.register.abc.com/myapp/administrator/registration
Which is :
http://www.register.abc.com is my domain
myapp is my aplication folder in server
administrator/registration is my controller and function
What I'd like to do is to remove this part /myapp/administrator/registration from my URL. In default, when user only enter the http://www.register.abc.com/ it will be redirected to my home page. I'd like to set it so the user directly enter registration page not the home page. I have little to no knwledge about .htaccess. Any help is greatly appreciated.
Note: I am using wiredesignz codeigniter modular extensions hmvc
Edit:
my current .htaccess is like this:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /myapp
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
In your site root .htaccess (a level above myapp/ you may try this .htaccess code:
RewriteEngine On
RewriteRule ^$ myapp/administrator/registration [L,R=302]
If you want an internal rewrite (without changing URL) then try:
RewriteRule ^$ myapp/administrator/registration [L]
I'm trying to rewrite /streams/post.php?id=1 into /streams/thread/1 .
I did find some codes for .htaccess with parameters but it didn't work in the subfolder.
Also, should I put another .htaccess in the subfolder or use the one on the main directory? ( /.htaccess or /streams/.htaccess)
Also, in the past when I've rewritten, sometimes it redirects from for example /streams/thread/1 to /streams/post.php?id= and sometimes it actually displays /streams/thread/1 in the URL, I would like it to display /streams/thread/1 in the URL, not just redirect.
You can put your htaccess in root or streams folder (that's up to you).
In root folder
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} \s/streams/post\.php\?id=([0-9]*)\s [NC]
RewriteRule . streams/thread/%1? [R=301,L]
RewriteRule ^streams/thread/([0-9]+)$ streams/post.php?id=$1 [L]
In streams folder
RewriteEngine On
RewriteBase /streams/
RewriteCond %{THE_REQUEST} \s/streams/post\.php\?id=([0-9]*)\s [NC]
RewriteRule . thread/%1? [R=301,L]
RewriteRule ^thread/([0-9]+)$ post.php?id=$1 [L]
There is such a structure of directories:
/public_html
/abc
.htaccess
Now all requests go to the folder /public_html. This is the code of .htaccess:
RewriteEngine on
RewriteCond %{REQUEST_URI} !public_html/
RewriteRule (.*) /public_html/$1 [L]
What should I do for that the requests like [the website address]/abc/* redirect to the folder /abc instead of /public_html?
Something like that:
example.com/* - go to /public_html
example.com/abc/* - go to /abc
Thanks! And I'm sorry for my English!
RewriteCond %{REQUEST_URI} !public_html/
Means that you want to rewrite if the REQUEST_URI does not contain public_html/. So to make sure you are not rewriting a URI with abc/ you need another condition that says so add
RewriteCond %{REQUEST_URI} !abc/
after the first RewriteCond and it should work. Now you say that if it does not contain either abc/ or public_html/ rewrite the url.
I m sure that many people will say that this is duplicated but I try everything from other "Question"`s and nothings work for me.
The problem is that I move my project to the web server.
In this server I have folder "public_html" where I but my project Symfony.
Now to enter on my project I must write the following url: www.mydomain.com/Symfony/web/*
But I want to write a Rewrite Rule which will redirect from www.mydomain.com/Symfony/web/* to
www.mydomain.com/home/*.
To do this I try on 2 different ways with many combination of ReWrite rule.
In my public_html I create a .htaccess folder
I edit the .htaccess in Symfony/web folder
I add the following rule in both file but without success
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^Symfony/web/(.*)$ www.mydomain.com/home/$1 [L,R=301]
Unfortunately without success. What I`m doing wrong?
My htaccess file look like
And all the time Error 404 Object not found
Symfony/web/.htaccess
DirectoryIndex app.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /Symfony/web/
RewriteCond %{THE_REQUEST} \s/+Symfony/web/ [NC]
RewriteRule ^(.*)$ /home/$1 [L,R=301]
RewriteRule ^home/(.*)$ $1 [L,NC]
</IfModule>
It`s redirecting me but I receive again Object not found :(
I delete the .htaccess in public_html folder which is the root one for my server
public_html\.htaccess
RewriteEngine On
RewriteRule ^home/(.*)$ /Symfony/web/$1 [L,NC]
1: Place this code in /Symfony/web/.htaccess:
RewriteEngine On
RewriteBase /Symfony/web/
RewriteCond %{THE_REQUEST} \s/+Symfony/web/ [NC]
RewriteRule ^(.*)$ /home/$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [L]
2: Place this code in /public_html/.htaccess:
RewriteRule ^home/(.*)$ /Symfony/web/$1 [L,NC]
I'm going to go out on a limb and say that your rule is backwards. I think you want your URL to be www.mydomain.com/home/* in the browser... In which case the rule would be reversed. Also, your .htaccess should be in the root and you don't need to include the domain in the rewrite rule because you set a rewrite base.
RewriteRule ^home/(.*)$ Symfony/web/$1 [L,R=301]
currently i have a /en/ folder that is empty except for a .htaccess with the following
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)$ ../index.php?language=en$1 [NC]
i use it to eliminate the need for
index.php?language=en
in all my URLs. I would like to modify the htaccess in a way that i no longer need the /en/ folder with nothing but the htaccess inside. ideally i would like an htaccess in my root folder that reads the url and if it is www.example.com/en/ to rewrite to www.example.com/index.php?language=en
This should work for you:
RewriteRule ^en/(.*)$ index.php?language=en$1 [NC]
Put the following code in .htaccess file in your root folder.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^en/(.*)$ index.php?language=en$1 [L]
Here $1 will append rest of the url as well. The condition will also help if you request your files using direct url.