I have a small script that creates a url
<a href="index.php?username=<?php echo $user['name']; ?>" >View Profile</a>
The problem is the url shows
http://pimpedryde.com/cars/index.php?username=bimmerguy
I was wanting the url to look more like
http://pimpedryde.com/cars/bimmerguy
I've tried a few htaccess codes without success. Any Ideas?
This is a working example of code igniter Project, Try this one.
<IfModule authz_core_module>
Require all denied
</IfModule>
<IfModule !authz_core_module>
Deny from all
</IfModule>
#<IfModule mod_rewrite.c>
# RewriteEngine On
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteCond %{REQUEST_FILENAME} !-d
# RewriteRule ^(.*)$ index.php/$1 [L]
#</IfModule>
Maybe this works
RewriteEngine On
RewriteRule ^http://pimpedryde.com/cars/(.*)=(.*)$ http://pimpedryde.com/cars/$2 [R=301,L]
OR
RewriteRule ^cars/(.*)=(.*)$ http://pimpedryde.com/cars/$2 [R=301,L]
This did it for me.
RewriteRule ^([^\.]+)$ index.php?username=$1 [L]
This is a great little tool for testing: http://htaccess.madewithlove.be/
You are in a sub-folder, so you need the RewriteBase clause, like this:
RewriteEngine On
RewriteBase /cars/
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ index.php?username=$1 [L]
That should do it.
Related
I've been trying to solve this for some time, and have tried a few suggestions which I found, but none of them seem to work
I would like to try and force a slash at the end of the URL for any page visited on my site, so rather than
www.example.com/about
it forces
www.example.com/about/
My .htaccess looks like
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ local/ [L]
RewriteRule (.*) local/$1 [L]
</IfModule>
Could anyone help?
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*[^/])$ /$1/ [L,R=301]
try this
I am trying to redirect http://example.com/for-sale/?property=1234 to http://example.com/for-sale/property-name/ in .htaccess, using RewriteCond and RewriteRule. This is what I have so far:
RewriteCond %{QUERY_STRING} ^(property=1234)
RewriteRule ^$ /for-sale/property-name/? [R=301,L]
This does not work. I can redirect ?property=1234 to for-sale/property-name/ but how do I get it to work with /for-sale/ in the un-redirected URL? I've tried various combinations of for-sale in the RewriteRule but without success.
Thanks.
All my links are now broken so I would really appreciate some advice. Thanks.
This is a wordpress site, so the first mistake was to do the rewrites after wordpress does its rewrites. Second mistake was in the RewriteRule. Here is the working code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} property=1234$
RewriteRule ^for-sale/?$ /for-sale/property-name/? [R=301,L]
... my other rewrites
</IfModule>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
This works. Hope it helps someone else out.
I have a page locally that is /shop but I want it to redirect to /shop/designs
I tried to do it with .htaccess but nothing seems to be working.
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^/shop/.*$ /shop/designs/ [R=301,L]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Any ideas where I am going wrong?
You were almost there, but in htaccess, you cannot use / at the beginning of the path regex.
Change your rule like so:
RewriteEngine On
RewriteRule ^shop$ shop/designs [R=301,L]
How can I use htaccess to redirect a few static pages and keep the same url?
Example :
Redirect www.mydomain.com/url-that-remains.php to www.mydomain.com/page-number-23
My current htaccess file looks like that:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
This code should work:
RewriteEngine On
RewriteRule ^url-that-remains\.php$ /page-number-23 [L,NC]
Try like this
RewriteEngine On
RewriteRule /somestaticpageonyourwebsite.html /yournewpage.html [R=302]
EDIT:
I don't know why the above doesn't work. This should work.
RedirectPermanent /somestaticpageonyourwebsite.html /yournewpage.html
I'm newbie with htacces..
I've file htaccess like this
Options -Indexes
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
I called url like this without index.php it's work
http://localhost/url/
but when I try to call
http://localhost/url/controller/
and
http://localhost/url/controller/method/
the page back to xampp's home.
so what would I do? I want url without index.php.
thank you very much every advice.
Looks like you need something simple like:
RewriteEngine on
RewriteCond $1 !^(index\.php|assets|media|favicon\.ico|ipadicon\.jpg)
RewriteRule ^(.*)$ /index.php/$1