I want to be able to create the url: http://example.com/+/user
Is it possible using .htacess rewrite.
I have searched the web and have come across nothing relevant to what I want.
You have to use really simple RewriteRule...
RewriteRule ^\+/user$ /test.php [PT,L,QSA,NC]
Or if you want to "catch" username from address, you have to use something like this
RewriteRule ^\+/(.+)$ /test.php?username=$1 [PT,L,QSA,NC]
With whatever rewrite_mod options you need.
Not so much things to do, simple things are often better ones :
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^\+/(.+)$ index.php?user=$1 [L]
Related
In my website there are lot of ugly URLs and now I need to rewrite them to nice user friendly URLs.
These are some of ugly URLs from my website :
http://www.mydomain.com/profiles/tutors/index.php?code=1285&name=Ricky+Pointing
http://www.mydomain.com/profiles/centers/index.php?code=2285&name=City+&+Gills
http://www.mydomain.com/about.php
http://www.mydomain.com/contact.php.... and much more
So I am looking for nice user friendly solution to above ugly URLs, something like this :
http://www.mydomain.com/tutors/Ricky_Pointing.html
http://www.mydomain.com/centers/City_&_Gills.html
http://www.mydomain.com/about.html
http://www.mydomain.com/contact.html
I tried it something similar this in my .htaccess file..
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /profiles/tutors/index.php\?code=([0-9]+)&name=([^&]+)&?([^\ ]+)
RewriteRule ^profiles/tutors/index\.php /%1/%2/?%3 [R=301,L,NE]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9]+)/(.+)/$ /profiles/tutors/index.php?code=$1&name=$2 [L,QSA]
But still no luck.
Can anybody help me to do this?
Thank you.
I think you might be overcomplicating it with RewriteConds and such. You'll probably have rules like this:
RewriteRule ^about\.html$ about.php [L]
RewriteRule ^contact\.html$ contact.php [L]
RewriteRule ^tutors/(.*)\.html$ /profiles/tutors/index.php?name=%1 [L]
RewriteRule ^centers/(.*)\.html$ /profiles/centers/index.php?name=%1 [L]
You'll then have to modify your PHP scripts to look up the appropriate thing with that name without relying on having the code present. It'll also have to deal with the presence of underscores as existed in the original URL.
There is an issue with the htaccess rewrite conditions in my setup.
Currently I have the following code.
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://mydom.com/$1.php
This works fine for any base page making them look like this.
http://mydom.com/page
What I want to also be able to do is add parameters from the url if they exist. I have some pages that will be like this.
http://mydom.com/page?param=1&secondParam=2
What I've tried to do is add this.
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/(.*)/(.*)$ http://mydom/$1/$2/$3 [L]
RewriteRule ^(.*)/(.*)$ http://mydom/$1/$2 [L]
This made sense to me, because I thought if the condition didn't match, it would move on, but this gave me an internal server error.
What I ended up doing was setting up a separate rule for each page that could have multiple parameters like this.
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^page/(.)/(.)$ http://mydom.com/page.php?param=$1&secondParam=$2 [L]
RewriteRule ^page/(.*)$ http://mydom.com/page.php?param=$1 [L]
RewriteRule ^(.*)$ http://mydom.com/$1.php
This works, however you need to keep in mind relative links you may have in your site such as style sheets and javascript files. In my case, I had to replace all relative paths with full site paths, depending on the way you set up your site, it could take a while to replace.
Hi i've got another question
i have the simplest htaccess
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
it gives me friendly urls eg. www.mysite.loc/blog/
but i want to go further and have eg. www.mysite.loc/blog/?page=1 and www.mysite.loc/blog/?page=1&id=1
how can i do that ?
P.S. i've tried many solutions that i've found in google but nothing works
Maybe you want something like this:
RewriteRule ^(.*)$ /index.php?url=$1&%{query_string} [L]
This way, a request for /blog/?page=1 would get mapped to /index.php?url=/blog/&page=1 and /blog/abc/?page=3 would get mapped to /index.php?url=/blog/abc/&page=3.
You'd then parse $_GET['url'] to figure out what resource the browser asked for.
I give up. I have read through dozens of questions on here, even asked my own, I have tried numerous things, I just don't know what to do anymore.
I need to create url's out of the following formats: (NSFW links, be warned)
http://jbthehot.com/#page=1
http://jbthehot.com/home?func=viewphoto&id=2969
http://jbthehot.com/home?page=4
http://jbthehot.com/home?func=viewalbum&aid=75
I must be retarded because I simply do NOT understand htaccess. I try not to ask for all-done answers, but in this case, an actual clear, copy/paste answer for at least one of the above formats would really be helpful.
I repeat, I have tried a lot of things, so I'm obviously doing something wrong, or I'm not understanding the rules and conditions right, so a copy/paste answer that is SURE to work would really help me understand what I'm doing wrong here.
If it helps, the component used here is SIM Gallery, on Joomla and there are a couple of other rewrite rules in effect in the .htaccess , here they are:
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$ [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
#
Thank you for any help
RewriteEngine On
RewriteBase /
RewriteRule ^home/viewphoto/([0-9]+)$ home?func=viewphoto&id=$1 [L]
RewriteRule ^home/viewalbum/([0-9]+)$ home?func=viewalbum&aid=$1 [L]
RewriteRule ^home/page/([0-9]+)$ home?page=$1 [L]
So http://jbthehot.com/home/viewphoto/2969 would show you http://jbthehot.com/home?func=viewphoto&id=2969, etc
Ok, so I am wondering what is the correct way to do .htaccess so that a url like this
http://www.mysite.com/?page=spinme
looks like this
http://www.mysite.com/spinme
It still needs to load index.php
but I am not sure how to do it, I know sounds simple.
Also I need it not to effect images or style sheets that are already
http://www.mysite.com/(what ever the folder link)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?page=$1 [L]
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f //not to effect images or style sheets
RewriteCond %{REQUEST_FILENAME} !-d //not to effect directory's
RewriteRule ^(.*)$ index.php?page=$1 [L,QSA]
To make
http://www.mysite.com/?page=spinme
to look like
http://www.mysite.com/spinme
You first of all need to make each output of that URI to be
http://www.mysite.com/spinme
That step is very important (at least for the display, in terms of working, you can skip this step and your site will just work).
If you've managed that, in your .htaccess file, just add a single rule:
RewriteRule ^spinme$ index.php?page=spinme [L]
and you're done.
If you're concerned about Search Engine Optimization (SEO) you should use this URI instead:
http://www.mysite.com/?page=spinme
It will show the search engine that your site has pages and they have a name. That's additional information searchengines process nowadays, comparable to keywords in earlier days.
Hope this is helpful.