I want to remove the index.php from the url: http://mywebsite/index.php/.
I m using CakePHP pretty URLs, I removed all the .htaccess files:
/.htaccess
/app/.htaccess
/app/webroot/.htaccess
and uncommented the App.baseUrl on the core.php.
Thank you for your help!
you can try this. i have been using this for my codeigniter and i think this will work for you too.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [QSA,L,NC]
oh you dont want to use htaccess? . i misundestood your question.
Related
Inside my drupal project www.example.com I have codeigniter project folder which is not running without index.php in the url.
Pls suggest any solution
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
</IfModule>
In codeigniter URL rewriting will differ for servers. For linux you should use .htaccess file and for windows you should use web.config file. You can get those files by google it.
Now i use this code for my website.
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
This code convert all url of my website:
www.example.com/category/work.php
in
www.example.com/category/work
It's great, but my goal is:
www.example.com/category/work.php
in
www.example.com/category/work/
I need "/" at the end.
Is possibile? This is a typical feature of CMS.
I want it in my site built by me.
You can force trailing slash
RewriteRule ^((.*)[^/])$ $1/ [L,R=301]
Also check this Stackover answer
I'm having some htaccess issues with my wordpress blog. My previous url's were something like
article-name.html
Now I changed the structure to
blog/article-name.html
But I'm still getting 404 for old url's I shared on various other sites. I've tried adding in htaccess a rule, also tried "redirection" plugin with no success:
and in .htaccess I tried:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^((?!blog/).)*.html$ - /blog/$1.html [L]
</IfModule>
Your regex appears to be a problem, try this:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^((?!blog/).+?\.html)$ /blog/$1 [L,R=301,NC]
Change the RewiteBase
But your .htaccess is not an Original WordPress .htaccess. Why you dont use that?
I just moved my functional codeigniter project to a new web hosting provider and am now having challenges removing the index.php from the URL using a standard .htaccess mod-rewrite. Here is the .htaccess that was working fine:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
I found this discussion but I do not have root access to the apache server to make the suggested configuration change.
Using the provided .htaccess file above,
Works fine: http://www.mysite.com/index.php/plans
Doesn't work: http://www.mysite.com/plans
Any suggestions are appreciated.
If you really have to accept both forms of URLs likewise then you need two RewriteRules. Once accepting variants with then 'index.php' part and one without.
Something like this:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^index\.php/(.*)$ index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Your question's not very clear, but a common problem with mod_rewrite rules like this is that some servers need the request to be passed as a query. I.e. you'd need to change your last line to:
RewriteRule ^(.*)$ index.php?/$1 [L]
I found several topics on mod_rewrite on stackoverflow but none them solved my problem. I also tried tutorial on this website http://edrackham.com/apache/beginners-mod_rewrite-tutorial/
I have been trying to use mod_rewrite to get clean url. For example:
www.myweb.com/itemdetail.php?itemid=111234
to
www.myweb.com/itemdetail/111234 or
www.myweb.com/itemdetail/iphone
This is my .htaccess file content.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %(REQUEST_FILENAME) !-l
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
As suggested in stackoverflow, I added following rewriterule to above file
RewriteRule ^itemdetail/([0-9]+)/$ itemdetail.php?itemid=$1 [NC,L]
But this did not solve my problem. Any suggestion is appreciated.
You should make the last slash optional :
RewriteRule ^itemdetail/([0-9]+)/?$ itemdetail.php?itemid=$1 [NC,L]
On some servers you can't use a slash in a RewriteRule (I have the same problem). To check this try the following as your htaccess file:
RewriteEngine on
RewriteRule ^itemdetail-([0-9]+)/?$ itemdetail.php?itemid=$1
EDIT:
Of course your permalink would be www.myweb.com/itemdetail-111234