In my site I use "show.php?cat=1" type URLs. I want to change for SEO optimization this link types.
I have tried before but I can't understand how to do that.
# Root Host
-- Project Folder
--- index.php
--- show.php
--- css/js/ and other folders
My first purpose is change my links
show.php?cat=1 to show/1/
my code is
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^/show/(.*)$ show.php?cat=$1 [QSA,L]
But it doesn't work. I have a GET error. What's wrong?
And my css files gone to /show/css URL
I'am very angry, my css files gone but Get function doesn't work.
Thanks for help.
Edit: If I change show code to 'test' like that, page becomes 404. Why?
Note: I'am using WAMP Server 3, Apache Rewrite_module is working.
RewriteRule ^/test/(.*)$ show.php?cat=$1 [QSA,L]
"The requested URL /project1/test/1 was not found on this server."
Use:
Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteRule ^show/(.*)$ show.php?cat=$1 [QSA,L]
Without first / in htaccess RewriteRule pattern
Related
(Referring to http://www.webconfs.com/url-rewriting-tool.php -- using url http://mywebsite.com/urltest/product.php?categoryid=1&productid=10)
Enabled Apache Module -- Rewite_Module
I have created a page product.php
Write the code so that - it shows the content - when i request the page as:
http://mywebsite.com/urltest/product.php?categoryid=1&productid=10
Then I created .htaccess in my project root (that is, in /urltest/)
and added the following code to it:
Options +FollowSymLinks
RewriteEngine on
RewriteRule product/categoryid/(.)/productid/(.)/ product.php?categoryid=$1&productid=$2
RewriteRule product/categoryid/(.)/productid/(.) product.php?categoryid=$1&productid=$2
But, when I take: http://mywebsite.com/urltest/product/categoryid/1/productid/10/
I get the error:
Not Found
The requested URL /urltest/product/categoryid/1/productid/10/ was not found on this server.
(As I mentioned direct url, works fine - http://mywebsite.com/urltest/product.php?categoryid=1&productid=10)
Pl help
You have a rewrite base problem.
Have your code like this
Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteBase /urltest/
RewriteRule ^product/categoryid/([^/]+)/productid/([^/]+)/?$ product.php?categoryid=$1&productid=$2 [L]
Dear stackoverflow community users,
Here i am little bit trouble with url redirection problem.
Right now my webpage urls with index.php (http://www.mystore.com/index.php), and i am trying to redirect it on root domain with htacess file.
I place right code into htacess file but dont seems to work also if i make that blank. It also seems to not work, Website is also going to open with http://www.mystore.com/index.php url.
How can i make it proper?
Could you try code below?
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
</IfModule>
I have a single point of entry on my website
mysite.com/admin/index.php?View=List&Model=User
All access to the DB/application is through this index.php file.
I would like to clean my URL from what is shown above to.
mysite.com/admin/List/User
The idea is to remove the key 'Model and 'View'.
I have found this link that looks very similar.
PHP/Apache: Rewrite rules with .htaccess
in htaccess file insert this code :
RewriteEngine On
RewriteRule ^admin/([^/]*)/([^/]*)$ /admin/index.php?View=$1&Model=$2 [L]
The rewritten URL:
http://mysite.com/admin/List/User
this site very useful for generate rewrite URL
http://www.generateit.net/mod-rewrite/
Create a file named .htaccess in your web root if you haven't already got one with the following:
# Turn the rewrite engine on (skip this if already done)
RewriteEngine On
# Redirect admin/List/User/ to admin/index.php?View=List&Model=User
RewriteRule ^admin/([^/.]+)/([^/.]+)/?$ admin/index.php?View=$1&Model=$2 [L]
This might work:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^admin/([^/]+)/([^/]+) /index.php?View=$1&Model=$2 [NC]
Add to .htaccess in the root folder of your website.
Ok, I'm starting to think that the problem is me but... ¿What's wrong here?
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule testpage\.html http://www.google.com [R] #It works
RewriteRule ^mineral/([0-9]+)/?$ ver.php?id=$1 [NC,L] #It doesn't
I have a folder called "WebX" and this .htaccess inside it along with other files from the web.
mod_rewrite is working ok according to phpinfo and everything is running on localhost.
The most courious thing is that if I type localhost/WebX/testpage.html it redirects to Google
but unfortunately for me if I type localhost/WebX/mineral/1 it gives me 404. ¿What happens?
The problem you are having is caused by RewriteBase /. Your .htaccess is in a subdirectory /WebX/, but you are telling mod_rewrite to rewrite rules as if the current directory was /. It tries to load a file ver.php in your www-root, which doesn't exist. If you have verbose error messages with what file it tried to load, you'll notice it says that it tried to load /ver.php and not /WebX/ver.php as you might expect.
The rest you are doing, most notably using a relative url instead of a / prefixed absolute url, seems correct. The correct .htaccess to use would be:
Options +FollowSymLinks
RewriteEngine on
RewriteBase /WebX/
RewriteRule testpage\.html http://www.google.com [R] #It works
RewriteRule ^mineral/([0-9]+)/?$ ver.php?id=$1 [NC,L] #It now should work
I have a single point of entry on my website
mysite.com/admin/index.php?View=List&Model=User
All access to the DB/application is through this index.php file.
I would like to clean my URL from what is shown above to.
mysite.com/admin/List/User
The idea is to remove the key 'Model and 'View'.
I have found this link that looks very similar.
PHP/Apache: Rewrite rules with .htaccess
in htaccess file insert this code :
RewriteEngine On
RewriteRule ^admin/([^/]*)/([^/]*)$ /admin/index.php?View=$1&Model=$2 [L]
The rewritten URL:
http://mysite.com/admin/List/User
this site very useful for generate rewrite URL
http://www.generateit.net/mod-rewrite/
Create a file named .htaccess in your web root if you haven't already got one with the following:
# Turn the rewrite engine on (skip this if already done)
RewriteEngine On
# Redirect admin/List/User/ to admin/index.php?View=List&Model=User
RewriteRule ^admin/([^/.]+)/([^/.]+)/?$ admin/index.php?View=$1&Model=$2 [L]
This might work:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^admin/([^/]+)/([^/]+) /index.php?View=$1&Model=$2 [NC]
Add to .htaccess in the root folder of your website.