.htaccess php seo url - .htaccess

i have problem with seo links
website.com/member/.htaccess code:
RewriteEngine on
RewriteBase /member/
RewriteRule ^([0-9]{1,15})-(.*).html$ profile.php?id=$1 [L,NC]
website.com/member/123-nickname.html working fine but i want that link:
website.com/member/123/nickname.html i trying this .htaccess code:
RewriteEngine on
RewriteBase /member/
RewriteRule ^([0-9]{1,15})/(.*).html$ profile.php?lookup=$1 [L,NC]
url working but website looks like without .css
how to fix problem?

My guess is that you're using relative URLs for your styles. Browser tries to find CSS file starting form the /member/123/ directory. Try setting absolute URL, or add it to a base tag: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base

Related

Rewrite url via htaccess on apache server

I have a url which is
www.domain.com/index.php?route=ticketsystem/generatetickets
I want people who type in the url www.domain.com/contact to be redirected to the page index.php?route=ticketsystem/generatetickets however have the url bar still show /contact is that possible via htaccess and if so how? I tried the below
RewriteEngine On
RewriteBase /
RewriteRule contact /index.php?route=ticketsystem/generatetickets [L,QSA]
For your shown attempts, please try following .htaccess rules file. Make sure your index.php and .htaccess files are present in same directory/folder. Also better to use & rather than using / for query string.
Make sure to clear your browser cache before testing your URLs.
RewriteEngine ON
RewriteRule ^contact/?$ index.php?route=ticketsystem&generatetickets [QSA,NC,L]

Remove all parameters from specific URL

How do I get this original URL:
https://www.example.com/search-for-commercial-doors.html?format=json&task=suggestions.suggest&tmpl=component
To be rewritten to:
https://www.example.com/search-for-commercial-doors.html
Code that is not working:
RewriteEngine On
RewriteRule ^search-for-commercial-doors\.html$ /search-for-commercial-doors.html? format=json&task=suggestions.suggest&tmpl=component [L]
With your shown samples, please try following htaccess Rules file. Make sure your htaccess file is present along with search-for-commercial-doors.html in same folder, also clear your browser cache before testing your URLs.
RewriteEngine ON
RewriteCond ^(search-for-commercial-doors\.html)/?$ $1?format=json&task=suggestions.suggest&tmpl=component [NC,QSA,L]

My htaccess not working in my website but working in testing site

Finally, I managed to write htaccess code and tested it in http://htaccess.madewithlove.be/ and found its correct.
The way the URL is rewritten in this http://htaccess.madewithlove.be/ is working
but when I use the same htaccess code in my website is not working.
new URL http://192.168.1.190/qjyii2/yii2dev3/frontend/web/login.php
Actual URL http://192.168.1.190/qjyii2/yii2dev3/frontend/web/index.php?r=site/login
Htaccess code
RewriteEngine On
RewriteRule ^qjyii2/yii2dev3/frontend/web/([^/]*)\.php$ /qjyii2/yii2dev3/frontend/web/index.php?r=site/$1 [L]
My mod_rewrite is working fine in server. I did put this htaccess under /www/qjyii2/yii2dev3/ and its not working. Any help is highly appreciated.
If you're placing this in /www/qjyii2/yii2dev3/.htaccess then use this code:
RewriteEngine On
RewriteBase /www/qjyii2/yii2dev3/
RewriteRule ^(frontend/web)/([^/]*)\.php$ $1/index.php?r=site/$2 [L,NC,QSA]
.htaccess is per directory directive and Apache strips the current directory path from RewriteRule URI pattern.

URL rewriting in PHP using .htaccess: How to put `/` in URL?

I have a URL like www.test.com?id=other-flavor&pid=hannycakes.
I did above URL like www.test.com/other-flavor$pid=hannycakes using .Htaccess
but I need www.test.com/other-flavor/hannycakes.
For this If I use / in my URL it can take as a folder.
How resolve my problem. How to put / in URL?
Try this:
RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)$ /?id=$1&pid=$2 [L]

.htacess redirect

This may seem like a basic question, but I am not getting how to do it. Here is the Urls below.
Old Url : http://domain.com/index.php/items/view/item_name
New Url : http://domain.com/index.php/items/details/name/item_name
How do I do a permanent redirect with this set of old and new Urls in htaccess?
Put this code in your DOCUMENT_ROOT's .htaccess file:
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(items)/view/(.*)$ /$1/details/name/$2 [NC,L,R=301]
The following worked for me....
upload a .htaccess file to the folder where ur file exists with the following data (it should be on a new line in the htaccess file)
redirect 301 /some_dir/oldpage.htm http://www.newdomain.com/newpage.htm
and from what i read somewhere when you need to do the same for a dynamic page you can use the following
consider the page as
http://www.example.com/page.php?id=13
the redirect would be
RewriteEngine on
RewriteCond %{QUERY_STRING} ^id=13$
RewriteRule ^/page.php$ http://www.example.com/newname.htm? [L,R=301]
here is what i got on googling for this
http://www.tamingthebeast.net/articles3/spiders-301-redirect.htm

Resources