404 Error in htaccess clean url - php

I have a website but i am getting 404 error while using clean url for my post URL
.htaccess code is
RewriteEngine On
RewriteRule ^post/([^/.]+)/?$ post.php?post=$1 [L]
RewriteRule ^([^/.]+)/?$ index.php?page=$1 [L]
Files in Server is like :
index.php
post.php
.htaccess
all in one main public_html folder
this URL is working fine http://www.example.com/1
but i have 404 error in http://www.example.com/post/12345
i don't know what's problem... plz tell me what to do

Try turning off multiviews by adding this somewhere in your htaccess file:
Options -Multiviews

Related

.htaccess rewrite getting url not found

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?

.htaccess rewrite not working?

Instead of having a URL that looks like this:
www.website.com/developer.php?u=username
I have attempted to make the URL:
www.website.com/developer/username
with the following code in my .htaccess:
RewriteEngine On
RewriteBase /
# Change developer URL
RewriteRule ^([a-zA-Z0-9_-]+)$ developer.php?u=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ developer.php?u=$1
However when I type in the second URL, I get a 500 internal error stating that The server encountered an internal error or misconfiguration and was unable to complete your request.
I have some other .htaccess rewrite rules that remove the .php / html (ETC) extensions from URLs and also make the index.php file of a directory display when the directory is reached (e.g www.website.com/directory) as opposed to www.website.com/directory.index.php
Thank you!
Use this:
RewriteEngine On
RewriteRule ^developer/([^/]*)$ /developer.php?u=$1 [L]
It will give you:
www.website.com/developer/username
Try this code
RewriteEngine On
RewriteBase
//Change URL
RewriteRule ^developer/(.+)$ developer.php?u=$1 [R,L]

htaccess rewrite url folder/file to folder/file.php

I want ajax/file address to be redirected to ajax/file.php using .htaccess. I created a .htaccess file like below but that gives a 500 Internal Server Error.
RewriteEngine On
RewriteRule ^ajax/(.*)$ ajax/$1.php [L]
An additional information is that my website is working under a sub-folder. (localhost/myproject) RewriteRule ^ajax/(.*)$ /ajax/$1.php [L] redirects url to (localhost/ajax/file.php) instead of (localhost/myproject/ajax/file.php
Problem is that .* in your regex also matches file.php.
Use your rule like this:
Options -MultiViews
RewriteEngine On
RewriteRule ^ajax/([^./]+)/?$ ajax/$1.php [L]

redirect index.php url to root domain - not working

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>

URL rewriting-page not found error

In order to convert my dynamic URL i.e www.3idiots.co.in/index.php to static url i.e www.3idiots.co.in/index.html, I edited my .htccess file and put the following code in it:
RewriteEngine On
RewriteRule ^index.php$ /index.html [R]
when i uploaded this file in the root directory,and try to open the page, I got the error
404 page not found error, www.3idiots.co.in/index.html not found.
You have to actually have a file named index.html. Right now you don't. The rewriting/redirecting is working fine, you're just redirecting to a non-existent page/file.
I'm a little confused as to what you're actually trying to do. If you just want to move index.php to index.html, rename the file. Rewriting makes it so that if someone tries to open index.php they will be redirected to index.html, but you still have to have an index.html file for them to be redirected to.
RewriteEngine On
# Send the user to index.html
RewriteRule ^index.php$ /index.html [R]
# Tell the server that index.html really means index.php
RewriteRule ^index.html$ /index.php
Try these rules:
RewriteCond %{THE_REQUEST} ^GET\ /index\.php
RewriteRule ^index\.php$ /index.html [L,R=301]
RewriteRule ^index\.html$ index.php [L]
The first rule redirects every direct request of /index.php externally to /index.html. And the second rule rewrites requests of /index.html internally to /index.php.
Are you sure mod rewrite is enabled & working?
1) create an html page called found.html with whatever you want in it, but some text to be sure it's loaded (not a blank page basically) and put this in an file called ".htaccess" :
RewriteEngine on
RewriteBase /
RewriteRule ^find.html$ /found.html [L]
2) upload both your .htaccess and the found.html files in your domain's root
3) Just try to load -www.example.com/find.html (with your real domain of course). If mod_rewrite is available, you should see the content of found.html while browsing find.html (which does not physically exist by the way).
If it does not work, try :
RewriteEngine on
RewriteBase /
RewriteRule ^find.html$ found.html [L]
In the Apache Conf file, you also need to make sure that AllowOverride is set to a value that will allow .htaccess to be processed.
Normally it's AllowOverride all
RewriteEngine On
RewriteRule ^index.html$ index.php
RewriteRule ^$index.htm/$ index.php [L]
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^index.html$ index.php
Try this code...
It will work for your problem /..
Best Of LUck
If it solve your problem..
Visit my site

Categories