I'm new to the .htaccess thing and did a couple of routing which worked fine but i just realised that my $_GET[] is being discarded. please how do i fix this.
Below is my PHP code:
<?php echo $_GET['er']?>
and my .htaccess code:
#turn rewrite engine on
RewriteEngine on
Rewritecond %{REQUEST_FILENAME} !-d
Rewritecond %{REQUEST_FILENAME} !-f
RewriteRule ^signup/([0-9]+)$ -/register.php?er=/$1 [QSA,L]
Any help is much appreciated.
Thanks in advance.
Try this
RewriteRule ^signup/([0-9]+)$ -/register.php [QSA,L]
so when the request
http:.../register.php?er=test;
You can now $_GET["er"] from within your php file.
an example that worked for me
RewriteEngine on
Options -Multiviews
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
Related
I having issue for re-writing url from
http://localhost/cs/compare?slug=wash-safe-industries.html
to
http://localhost/cs/compare/wash-safe-industries.html
I have tried following code in .htaccess but does not work for me, I have also searched various sites but still facing issues
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?compare/(.*?)/?$ /compare.php?slug=$1 [L]
Also tried following line of code
RewriteRule ^cs/(.*)$ cs/compare.php?slug=$1 [L,QSA]
Please help me out thanks
Try this .htaccess in /cs/ sub-directory:
Options -MultiViews
RewriteEngine on
RewriteBase /cs/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^compare/(.+?)/?$ compare.php?slug=$1 [L,NC,QSA]
Try using following line of code:
Options -MultiViews
RewriteEngine On
RewriteRule ^compare/(.+?)/?$ compare.php?slug=$1 [L,NC,QSA]
You have to write as follows, try this one.
RewriteRule ^compare/wash-safe-industries.html compare?slug=wash-safe-industries.html
I am new in codeigniter and i am trying to remove index.php from URL in Codeigniter but not able to do this.
I wrote code in my .htaccess file-
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
My Apache mod_rewrite is enable.
But still got 404 error when i am trying to access any controller without using index.php.
Please help.
Thanks.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/index/?$ $1 [L,R=301]
</IfModule>
Is the code I'm using, it works on every hosting platform I've used it on.
This should help you,
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
check this code of htaccess file.
DirectoryIndex index.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|public|images|css|js|robots\.txt)
RewriteRule ^(.*)$ index.php?/$1 [L]
you can find your answer refference here
My .htaccess file is not working
moreover can you share your base url with us? as this error may be due to wrong baseurl set.
I need help with my .htaccess file. So far, nothing seems to work. I have made a PHP file called vote.php that uses GET variables to redirect the user to the appropriate voting website. Now, I want the user to be able to type myurl.com/vote1 which will redirect them to myurl.com/vote.php?vote=1 and so on vor /vote2, /vote3, /vote4 and /vote5
All help is appreciated!
Thanks,
Tanner
Put this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^vote([0-9]+)/?$ /vote.php?vote=$1 [NC,QSA,L]
For URL Rewrite or MOD_RE-WRITE in php.
Please go through this link..;
Mode_RwWrite Tutotial
Hope this Helps,
Thanks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ vote.php?vote=$1 [PT,L]
</IfModule>
I think you will still need to configure routing if you are not done with that ;)
Currently I have a url
www.mysite.com/folder/details.php?d=sample.com
and I want it to change like this one
www.mysite.com/folder/sample.com
This is my .htaccess file, but it is not working:
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ details.php?d=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ details.php?d=$1
I also tried this one, but its not working also:
RewriteEngine On
RewriteRule folder/([0-9]+) details.php?d=$1
This is my url link php code:
<?php echo $var['var']; ?>
I tried some of the answers I found in this site but still I cannot figured out what I am doing wrong. Anyone?
Thanks!
You need some conditions to prevent looping:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9_.-]+)/?$ details.php?d=$1 [L]
You can also combine the two rules into one by using the /? at the end to make the slash optional.
For the rules to be placed in the document root, you need to add the folder names to the pattern and the target:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^folder/([a-zA-Z0-9_.-]+)/?$ /folder/details.php?d=$1 [L]
Thanks for your comments #Jon Lin and #quasivivo , I found a solution to my problem, this is my htaccess:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^portfolio/(.*)$ /portfolio/details.php?d=$1 [L,QSA,NC]
and I also change my url link code:
<?php echo $var['var']; ?>
Hope this will help someone in the future.
I want to make my first api, but im having trouble setting up the urls. The api url is here:
http://tools.fifaguide.com/api/
So for example if some one goes to:
http://tools.fifaguide.com/api/player/messi
Then I need this page to be loaded:
http://tools.fifaguide.com/api/server.php
What do I write in .htaccess? and where should I put it?
This is what I have right now:
RewriteEngine On
RewriteRule ^api http://tools.fifaguide.com/api/server.php
But it doesnt do anything, also the htacces file is in the api folder.
Any help would be really apreciated!
This is what ended up working for me
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/api/ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ api/index.php [QSA,L]
////// wordpress stuff /////////
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
You might try this:
RewriteEngine On
RewriteRule ^api/(.*) http://tools.fifaguide.com/api/server.php [R,L]
And if you need the resulting url you could add this:
RewriteEngine On
RewriteRule ^api/(.*) http://tools.fifaguide.com/api/server.php?r=$1 [R,L]
Then in your script you could access the requested url with $_GET["r"] (assuming php...)
Also a helpful tool i've found for htaccess:
http://htaccess.madewithlove.be/
-Ken