Somehow when I use a specific friendly URL the rewriterule doens't work.
Does anyone know what I am doing wrong?
Below my code within the .httaccess file
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
When I try the following URL everything goes fine:
http://localhost/test/test
However when I use the following URL the rewrite doens't happen:
http://localhost/index/test
Thanks in advance.
Related
Hi I know absolutely nothing about mod_rewrite.
I'm asking how I could rewrite this URL as needed.
website.com?page=pagename&content=contents&action=download
as
website.com/pagename/contents/download
the param "action" will not always be set. Unsure if that makes a difference.
Try adding this to the htaccess in your document root:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ /?page=$1&content=$2&action=$3 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/?$ /?page=$1&content=$2 [L,QSA]
I'm getting a Rewrite Loop error for the following:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mysite.com [NC]
RewriteRule ^(.*)$ http://www.mysite.com/$1 [R=301,NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/(apps|site).* [NC]
RewriteRule .* http://site.mysite.com/ [R=301,L]
Why is this happening, what am I missing?
I've tested the following URLs, and they seem to redirect ok:
www.mysite.com/
www.mysite.com/apps
www.mysite.com/apps
mysite.com/
mysite.com/apps
mysite.com/apps/about
mysite.com/site
BUT
www.mysite.com/site
does not want to redirect, the rest all redirects to http://site.mysite.com as expected?
It turns out we had a site folder in our public, which somehow got the action before the .htaccess. Not sure why this happened, but upon removing this redundant folder, everything is working 100%
I am trying to redirect url in CodeIgniter framework with www.hostname.com/crm/some/url to www.hostname.com/index.php?/some/url
I wrote following rule in my .htacess
RewriteEngine on
RewriteRule ^crm(.*)$ index.php?/$1 [L]
When i try this in browser, i get page not found 404 from codeIngnitor. But if add [R] flag in the redirect rules, it works proper and i could see the new url as expected after the change.
I tried apache rewrite log. Everything looks proper. I have no what URL the CodeIgniter frame sees after rewrite. Any help is appreciated.
Is there a reason you're not using the typical Codeigniter .htaccess?
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
You can follow this, Do this code copy and paste in your .htaccess file. I think
it will help you.
RewriteEngine on
RewriteCond $1 !^(index\.php|(.*)\.swf|forums|images|css|uploads|themes|downloads|jquery|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php?$1 [L,QSA]
I have a routing problem in CodeIgniter.
I can access to my default controller (the login page) with the http://localhost/MySite. So I think the routing configuration is good.
When I submit the login form of my login page, I get a Not found error 404 and the URL displayed is http://localhost/MySite/login?
When I insert "index.php" (http://localhost/MySite/index.php/login) in the url, it works. In the documentation it's written that I must add some lines in .htaccess:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L,QSA]
What is wrong with this URL Routing?
Try this thing which i am using write now in my project........
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Please try this..
RewriteEngine on
RewriteCond $1 !^(index\.php|public|\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1
I hope it will be ok.
I need a very quick fix in a mod_rewrite expression for drupal we have
RewriteCond %{REQUEST_URI} !(\.gif)|(\.jpg)|(\.png)|(\.css)|(\.js)|(\.php)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
But i need to redirect the value of the subdomain in get too so i need something that will give:
RewriteCond %{REQUEST_URI} !(\.gif)|(\.jpg)|(\.png)|(\.css)|(\.js)|(\.php)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?subdomain=THE SUBDOMAIN HERE&q=$1 [L,QSA]
Don't know how to do it, please help!
Trying this again, for some reason my code isn't rendering properly.
RewriteCond %{REQUEST_URI} !(\.gif)|(\.jpg)|(\.png)|(\.css)|(\.js)|(\.php)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteCond %{HTTP_HOST} ^(.*)\.mydomain\.com$
RewriteRule ^(.*) index.php?subdomain=%1&q=1 [L,QSA]
Based off of some forum posts I found here.
You don't really need the subdomain in the query string.
The subdomain can be found in PHP in $_SERVER['SERVER_NAME'].
PHP documentation says:
'SERVER_NAME'
The name of the server host under which the
current script is executing. If the script
is running on a virtual host, this will be
the value defined for that virtual host.