I am trying to perform a url rewrite where a url like "http://localhost/mywork/product/MTg=/productinfo/" should appear like "http://localhost/mywork/MTg="
Also, the "MTg=" is dynamic and will be varying.
I am not sure as to how to achieve it, can anyone please suggest what RewriteRule i should be writting in my .htaccess
Create mywork/.htaccess file it doesn't exist and have this rule:
RewriteEngine On
RewriteBase /mywork/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ $1/productinfo/ [L]
Related
I want to rewrite this in SEO friendly url.
From - www.example.com/section.php?name=website
To - www.example.com/section/website
I tried this:
RewriteEngine On
RewriteRule ([^/\.]+)/([^/\.]+)?$ section.php?type=$1&service=$2 [NC,L]
I am fetching data using GET method in section.php and pass to the another page but after opening sub folder like www.example.com/{foldername} it returns to the section.php
Thanks. I will appreciate your help.
With your shown samples, please try following htaccess Rules file. Please make sure you clear your browser cache before testing your URLs.
RewriteEngine ON
##Rules for rewrite to section.php as per OP's request.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/?$ section.php?name=$1 [L]
This helps me
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
RewriteRule ([^/\.]+)/([^/\.]+)/?$ search.php?type=$1&service=$2
i have been trying to make my urls "pretty" / human readable, the urls at the moment are:
[BASE_URL]/?action=viewProposal&proposaltitle=tesst
I want to rewrite them to be just [BASE_URL]/tesst
I tried using the following code and modifying it but it wouldn't work, ie. it didn't redirect the pages but didn't throw any errors.
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^users/(\d+)*$ ./profile.php?id=$1
RewriteRule ^threads/(\d+)*$ ./thread.php?id=$1
RewriteRule ^search/(.*)$ ./search.php?query=$1
Will the PHP GET functions still work properly as ?action defined whether its a view / edit / delete?
I am assuming base url your index.php try following rule,
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\w-]+)$ index.php?action=viewProposal&proposaltitle=$1 [QSA,L]
I am attempting to create an seo friendly url system.
Sample:
/category would get information from cat.php?cat=category
My issue is that I want to keep that url and be able to do something like the following
/category?page=2&sub=1
or
/category/?page=2&sub=1
I was able to get the folders to redirect to the cat.php file but I cant seem to figure out the second half.
#Create redirect for all nonexistant folders to the category file
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/(.+)$
RewriteRule ^(.*)/? cat.php?cat=$1 [L]
If I am understanding you this should be what you need.
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ cat.php?cat=$1 [QSA,L]
So if you were to use a URL like this
http://www.yoursite.com/category?page=2&sub=1
The RewriteRulewill direct it to cat.php?cat=category&page=2&sub=1
You're lacking the QSA flag at the very least. Without QSA, the existing query string is simply replaced by the new query string.
Here is my .htaccess :
RewriteEngine on
RewriteBase /site
RewriteCond %{request_filename} -f
RewriteRule ^(.*) $1 [L]
RewriteRule ^([a-z]+)(/([^/]{0,32})(/.+)?)?$ index.php?a=$1&u=$3 [L]
I am trying to have short urls in this manner
if someone goes to www.mysite.com/johndoe htaccess sends him/her to this link index.php?a=profile&u=johndoe
what would be the best way to do this? I did read htaccess tutorials and tried different ways and failed :/
Try inverting the condition and remove the rewrite base:
RewriteEngine on
RewriteCond %{request_filename} !-f
RewriteCond %{request_filename} !-d
RewriteRule ^([^/]+)/?$ /index.php?a=profile&u=$1 [L]
This will make it so:
if someone goes to www.mysite.com/johndoe
The "johndoe" gets matched by ^([^/]+)/?$ and backreferenced by $1, resulting in:
this link index.php?a=profile&u=johndoe
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]