I have problem with my redirection rule in my website, i haven't this problem localy.
There is my project hierarchy:
1. my_website :
1.1 -->.htacess (1)
1.2 -->webroot
1.2.1 -> .htaccess (2)
1.2.2 -> index.php
htacces (1) :
RewriteEngine On
RewriteRule (.*) webroot/$1 [L]
htacces (2) :
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) index.php/$1 [L]
When i enter link like : www.xxx.com/my_website,the redirection for my index.php work fine.
But if i enter link like www.xxx.com/my_website/folderName/action,i have an error (File not found).
thanks for your help.
Related
Im'm trying to remove this /web from the url in Yii2 basic temeplate with .htaccess files. And i found a solution for it already but a problem has occured!
So the solution i have found earlier is:
1)Put in root/web folder .htaccess:
RewriteEngine On RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
2)Put in root folder .htaccess:
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/(web)
RewriteRule ^assets/(.*)$ /web/assets/$1 [L]
RewriteRule ^css/(.*)$ web/css/$1 [L]
RewriteRule ^js/(.*)$ web/js/$1 [L]
RewriteRule ^images/(.*)$ web/images/$1 [L]
RewriteRule (.*) /web/$1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /web/index.php
3)Add in config/web.php in request part 'baseUrl'=> ''
The problem occured after steps 2 and 3 are made. Browser tells:
Not Found
The requested URL /web/index.php was not found on this server.
Apache/2.4.23 (Win64) PHP/5.6.25 Server at localhost Port 80
All this happens when I'm doing it on my local server wich is WAMP. I tried to place this project on free hosting and evrything seem to work there. So how can I fix this problem on my local server? Why does it give me the 404 error?
Try in the root .htaccess replace
RewriteRule (.*) /web/$1
on
RewriteRule ^(.*)$ /web/$1 [L,PT]
After some help from another question i managed to figure out about .htaccess on my website for Friendly SEO links.
My public_html folder contains those files
index.php
.htaccess
buisnessdetails.php
eventDetails.php
My htaccess so far is this
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(.*)\ (.*)$ /$1-$2 [L,R=301]
RewriteCond %{THE_REQUEST} /eventDetails\.php\?id=(.+)&name=(.+)\sHTTP [NC]
RewriteRule ^ /%1/%2? [L,R]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/([^/]+)/?$ /eventDetails.php?id=$1&name=$2 [L]
</IfModule>
So when someone clicks an href which has http://sourtouki.gr/123/abc
the htaccess file goes to the
eventDetails.php file.
But now i want it to change like this
i've edited my public_html folder like this
index.php
events(folder)
2.1 eventDetails.php
buisness(folder)
3.1 buisnessdetails.php
So with these changes i want to do the following thing
Changed the href link to
http://sourtouki.gr/events/123/abc
What changes i must do to the .htaccess file so it can understand that if someone pushes the above link, to go to the eventDetails.php which is inside events folder??
And is it going to be editable so i can add also buisness folder inside that rewrite rule?
You can use something like :
RewriteEngine on
RewriteRule ^(.*)\ (.*)$ /$1-$2 [L,R=301]
RewriteCond %{THE_REQUEST} /events/eventDetails\.php\?id=(.+)&name=(.+)\sHTTP [NC]
RewriteRule ^ /events/%1/%2? [L,R]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^events/([^/]+)/([^/]+)/?$ /events/eventDetails.php?id=$1&name=$2 [L]
I am trying to change the URL from:
/chat/create?ref=9dsda to /chat/create/refer/9dsda
However, everytime I go to the lather, I get the error:
Not Found: The requested URL /chat/create/ref/9dsda was not found on this server.
This is my .htaccess file:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/create/refer/([^/]+) /create?ref=$1
I've tried several things such as adding RewriteBase /chat/ without success.
If your htaccess is in the root ,try :
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^chat/create/refer/([^/]+)/?$ /chat/create?ref=$1 [L]
If it is inside the /chat dir ,try :
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^create/refer/([^/]+)/?$ /chat/create?ref=$1 [L]
htaccess is a per-directory context so you don't need to match against the folder that the htaccess is in.
I using Joomla Joomla! 3.4.4 and also XMAP Component 2.3.3
Now i want to Rewrite url when url was :
/index.php?option=com_xmap&view=xml&tmpl=component&id=1
Rewrite
/sitemap.xml
This is my code that i wrote in htacces file,i dont know why doesn't work
RewriteCond %{REQUEST_URI} ^/sitemap.xml
RewriteRule .* /index.php?option=com_xmap&view=xml&tmpl=component&id=1 [L]
You can give this a try.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^sitemap\.xml$ /index.php?option=com_xmap&view=xml&tmpl=component&id=1 [L]
When I go to http://www.example.com/youtube/detail/abvcde in my browser, I want to internally rewrite the url to http://www.example.com/youtube/detail.php?id=abvcde. I tried to do this with the following .htaccess, but it gives a 404 error.
Currently my .htaccess looks like this:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) $1.php [L]
Put the following code in a htaccess file in server root directory:
RewriteEngine On
RewriteRule ^youtube/detail/(.+)$ youtube/detail.php?id=$1 [L]
You can put this code in your /youtube/.htaccess
Options -MultiViews
RewriteEngine On
RewriteBase /youtube/
RewriteRule ^detail/([^/]+)$ detail.php?id=$1 [L]