(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]
Related
I am trying to rewrite URL's using .htaccess methods. This is working on localhost when XAMPP is used, but when I put it on the server it just doesn't.
Here is an example of the code used:
RewriteEngine On
Options +FollowSymLinks
Options -Indexes
DirectorySlash Off
RewriteRule ^contacts?$ contacts.php
RewriteRule ^example?$ tester.php?number=1
RewriteRule ^anotherexample?$ tester.php?number=2
I get this error message:
The requested URL /AMENPTHOME/hostnd/b/5/6/b56a95b8c/www/htdocs/public/new/produto_individual.php was not found on this server.
Can someone help?
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
I am trying to use php`s module mod_rewrite to get rid of .php extensions in URL.
I`ve got 2 files in root directory .htaccess and team.php.
My .htaccess file contains following code. Consider each scenario separately.
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
# Scenario 1 - http://localhost/team response with code 404
# The requested URL /team was not found on this server.
RewriteRule ^team$ team.php [NC]
# Scenario 2 - http://localhost/teams successfully redirect to team.php
RewriteRule ^teams$ team.php [NC]
# Scenario 3 - http://localhost/team response with code 404
# The requested URL /team was not found on this server.
RewriteRule ^team$ index.php [NC]
# Scenario 4 - http://localhost/teams response with code 404
# The requested URL /index.php was not found on this server.
RewriteRule ^teams$ index.php [NC]
</IfModule>
This means only Scenario 2 and Scenario 4 works properly and adds .php extension to URL. What is wrong with Scenario 1 and 3 ?
I also tried to use one more file about.php but it behaved the same way as team.php. For example request for localhost/about resulted in 404 /about not found on this server (Scenario 1).
How do i rewrite localhost/team request to load team.php file ? Is there possibly something wrong with the configuration, missing module or something with wrong permissions ?
As anubhava said in his comment:
Try changing Options line to this: Options +FollowSymLinks -MultiViews
This solved my problem and now RewriteRule works exactly as expected.
Looking to re write a url in WAMP. I have AllowOverride Al (conf file). The mod rewrite modules is loaded. I am working on localhost
What i want to acheive is that on login the user gets redirected
localhost/propcms/xxxxxxx/
the actual address is
localhost/propcms/status.php?id=xxxxxxx
the .htaccess file has the following (and is located in localhost/propcms/ )
Options +FollowSymlinks
RewriteEngine on
RewriteBase /propcms/
RewriteRule ^propcms/([^/]*)/$ /propcms/status.php?id=$1 [L]
this is what i get....The requested URL /propcms/test121/ was not found on this server.
any ideas ??
Since you are specifying a rewritebase, you should not include it in your rewrite rule:
Try this snippet :
Options +FollowSymlinks
RewriteEngine on
RewriteBase /propcms/
RewriteRule ^([^/]*)/$ /propcms/status.php?id=$1 [L]
I would like to write a rule where the members/show/ string will be hidden in the URL.
The original URL: localhost:8080/sandbox/member/show/helloworld, where helloworld is the name of the account. I'd like it to be localhost:8080/sandbox/m/helloworld. Basically, the content delivered will be from the full url, but I'd like it to be hidden for any user.
RewriteRule ^.*$ member/show/$0 [L,QSA] doesn't seem to work, it throws a 500 Internal Server Error. I work with the CodeIgniter Framework, and the following rewrite rule is already present: RewriteRule .* index.php/$0 [PT,L].
I tried several RewriteRule options but without success. I'd be very glad if anyone could shed some light related to my question.
Best regards.
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^(sandbox)/m/([^/]+)/?$ /$1/member/show/$2 [L,NC]