Currently my website does this when you go to whoever's profile:
index.php?a=profile&u=berdyev
I would like to make it look like:
website.com/berdyev
Any suggestions?
Thank you.
Place this in your root .htaccess:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ /index.php?a=profile&u=$1 [L,QSA]
Related
My code produce URL like this:
http://domain.com/netRacuni/tcpdf/examples/pdf.php?key=bi5u3w2zys1v9sqijomsqyya5ge2v5
How I can make it like this:
http://agroagro.com/bi5u3w2zys1v9sqijomsqyya5ge2v5
so only domain.com+key to be there?
You can a try a rule like this in your root .htaccess.
RewriteEngine On
RewriteCond %{QUERY_STRING} ^key=(.+)$
RewriteRule ^netRacuni/tcpdf/examples/pdf.php$ /%1? [L]
Edit: Sounds like you want it the other way around. Your question isn't too clear.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ /netRacuni/tcpdf/examples/pdf.php?key=$1 [L]
How can i rewrite this in .htaccess correctly?
So I have a query string in my url:
/index.php?page=pageCount&subject=mySubject
I want to change it to:
/index/pageCount/mySubject
and also
/show.php?subject=mySubject
to
/mySubject
and also
search.php?key=myKey
to
/key/myKey
thanks
In your .htaccess file
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^index/([^/]+)/([^/]+)$ index.php?page=$1&subject=$2 [L,QSA]
RewriteRule ^key/([^/]+)$ search.php?key=$1 [L,QSA]
RewriteRule ^([^/]+)$ show.php?subject=$1 [L,QSA]
Can anyone help me to rewrite my URL like this using .htaccess :
http://website.com/name-of-category/title-of-the-article
need to be rewritten to
http://website.com/name-of-category#title-of-the-article
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
Something like this ?
RewriteRule ^([^/]+)/(+.)/$ /#$1 [L,R,NE]
Thank you in advance !
You can use this rule in root .htaccess file:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/(.+)/$ /$1#$2 [L,R=302,NE]
The URLs of my site are of the type
http://localhost/cms2/pages.php?mpage=2
I have written the following .htaccess in order to create pretty URLs, but nothing happens
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([0-9]+)\/$ pages.php?spage=$1 [NC]
Mod-rewite is ennabled and other rewrite rules I've tested work. For example, I have a file called "contact-us.php". I can make it look "mysite.com/contact-us" using the following code:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
RewriteRule ^(.*)\.html$ $1.php [nc]
Any help would be appreciated.
Thanks in advance.
Sonia
Not working because your regex is incorrect. Use this rule in your root .htaccess:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([0-9]+)/([^./]+)/?$ /cms2/$2.php?spage=$1 [L,QSA]
This will rewrite a pretty URI: /3/page/ to /cms2/page.php?spage=3
I had this code before
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /lr/profile.php?username=$1
But that makes the profiles go to coolsite.com/Something I want the profile link go to /profile/Something instead of profile.php?username=Something
How can i do that?
Unless there is more to your question then I'm seeing, simply changing your RewriteRule to something like the following should do the trick.
RewriteRule ^profile/(.*)$ /lr/profile.php?username=$1