I have a very simple piece pf code. I want to enter some word in URL and wants that it should stay on the same page.
My index.php file is
<?php
echo "sample test";
?>
My htaccess file is
RewriteEngine on
RewriteCond % {REQUEST_FILENAME}!-d
RewriteCond % {REQUEST_FILENAME}!-f
RewriteRule ^(.*)$index.php?url=$1[L,QSA]
Both file are placed in the kite folder of wamp directory.
When I type localhost/kite then the index page appears. But when i write something more after kite for example localhost/kite/about then it says requested url is not found.
I have turned on all rewrite_module in wamp.
The following is correct and working. You were almost there, your spacing was just off a little.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php?url=$1 [L,QSA]
You can try like this
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /kite/index.php/$1 [L]
or
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
Related
I have problem while trying to use below .htaccess file to direct my requests. every one begin with rest to rest.php and others to index.php. the problem is all request directed to index.php even the ones begin with rest. did i miss something ?
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^rest(.+)$ rest.php? [QSA,L]
RewriteRule ^(.+)$ index.php? [QSA]
below .htaccess seems to solve my problem, please if there is a bug, write it in comment.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^rest$ rest.php? [QSA,L]
RewriteRule ^rest(.+)$ rest.php? [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php? [QSA]
Can't figure out what I'm doing wrong.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)\.php$ detail.php?name=$1 [NC,QSA,L]
RewriteRule ^(.+)/directory/\.php$ detail2.php?name=$1 [NC,QSA,L]
The first RewriteRule should redirect anything (ending on php like domain.com/product1.php) from the root domain to detail.php (it can not affect things like domain.com/contact.php)
A 2nd RewriteRule should redirect anything from domain.com/directory/product-b1.php to detail2.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* /foldernamehere/index.php/$0 [PT,L]
paste this code in your .htaccess file it will resolve your problem
i used the htacess to remove the php extension and it worked but i also have a page called profile wich i shorten but that make the pages names being taken as a a profile user name, is there a way to fix this?
the results i want is like this:
localhost/path_folder/index.php to localhost/path_folder/index
and
localhost/path_folder/profile?username=name to localhost/path_folder/name
and my htaccess code for the removing extension is:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC]
and the code for the profile page is:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /path_folder/profile.php?username=$1
Put this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
## First try To internally redirect /dir/file to /dir/file.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ /path_folder/$1.php [L]
## if PHP file not found then load profile page
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+?)/?$ /path_folder/profile.php?username=$1 [L,QSA]
If you want to remove file extension
RewriteEngine On
RewriteRule ^path_folder/([^/]*)$ path_folder/$1.php [L]
Shorten URL for userprofiles
RewriteEngine On
RewriteRule ^path_folder/profile/([^/]*)$ path_folder/profile?username=$1 [L]
i'm trying to make a codeigniter based website be able to convert index.php?option=test&controller=con1 to /test/con1 using .htaccess i tried multiple examples i found and none seem to work, it goes straight to the home page. any ideas?
i've tried things like
RewriteCond %{QUERY_STRING} ^(\w+)=(\w+)$
RewriteRule ^\/(.+?)\/(.+?)\/? /index.php/$1/$2 [L]
but doesn't throw any errors or anything.
my current htacces is
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|img|js|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
try put this .htaccess in same directory with your index.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
I am having a tough time to understand how mod_rewrite works.
I have a url like this:
www.example.com/store/index.php?categ=headbands
And I want to make it look like this:
www.example.com/store/headbands
I am trying this, but not working:
RewriteEngine on
RewriteBase /store/
RewriteRule ^index/([^/\.]+)/?$ $1 [L]
And I confirmed the mod_rewrite is activated with a random example I found.
Any suggestions?
Thanks!
Try This one
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^/store/(.*)$ /store/index.php?categ=$1 [NC,L]
OR
Put the .htaccess file inside the "store" directory with following code:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ index.php?categ=$1 [NC,L]