I created a virtualhost with MAMP. It works well when I go to example.dev. I just installed a wordpress on example.dev without any problems. When I display a page or a post, there is a /index.php which is added before the page name. For example : example.dev/index.php/pagename.
I can not access example.dev/pagename, i have a 404 error.
In permalink's options, it generates automatically /index.php/%year%/%monthnum%/%day%/%postname%/.
I selected http://example.dev/example-article/ but it is still not working.
I have a htaccess at the root
RewriteEngine On
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
If somebody has an idea...
Thank you !!
To this url /index.php/%year%/%monthnum%/%day%/%postname%/ will work on Apache server add this rule to .htaccess file
RewriteRule ^index.php/(.*)/?$ /$1/ [L]
Above the WordPress rules:
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
Given that your .htaccess have the basic WordPress rules it would look like this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php/(.*)/?$ /$1/ [L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
END WordPress
Related
I would like to redirect path like this
http://www.example.com/uploads/2017/10/image.ext/version/?id=87988984632
to
http://www.example.com/uploads/2017/10/image.ext
where extension could be whatever image or video extension.
I'm can detect the last part with this \/version\/(.*)$ but I can't remove from the uri.
Update:
This is my .htaccess and I'm using Wordpress
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteRule \/version\/(.*)$
</IfModule>
Thanks for your help
You can use this new redirect before other WP rules:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(.+)/version/?$ /$1? [L,NC,NE,R=301]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Currently the .htaccess file reads:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
What I am trying to do is route all sub page traffic of
/record-detail/what-ever-record
to:
/record-detail/?record_id=what-ever-record
This is taking into consideration there is already a rule for all urls routing to index.php.
Just add the rule before the other wordpress rules like so.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#RewriteRule ^record-detail/([^/]+)/?$ record-detail/?record_id=$1 [QSA,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_URI} !^/record-detail [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [QSA,L]
</IfModule>
# END WordPress
My website at www.tripfelt.com uses the .htaccess below to handle pretty URLs:
Options +FollowSymLinks
# enable rewrite engine
RewriteEngine On
RewriteRule ^blog - [L,NC]
RewriteRule ^robots.txt - [L]
RewriteRule ^$ index.php?/ [QSA,L]
RewriteCond %{REQUEST_URI} !^/blog
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php?/$1 [QSA,L]
www.tripfelt.com/blog uses the following .htaccess:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
However, clicking on any blog item, instead of opening the blog story, is redirecting to the main site. Any ideas what I am doing wrong?
Try changing the base in your blog folder to /blog/ and remove the leading slash in the routing rule:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>
# END WordPress
Solved
Blog folder
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
# END WordPress
The line of code:
RewriteRule ^/test/(.*)/?$ http://test.com/test/index.php?route=$1 [L,QSA]
has no effect in the htaccess file that I am using:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteRule ^/test/(.*)/?$ http://test.com/test/index.php?route=$1 [L,QSA]
</IfModule>
# END WordPress
When I visit my domain.com/test/123, Wordpress redirects be to a 404 page not the new link.
I have tried moving the items in the htaccess file around in case they are being overwritten, but not luck. any ideas?
Problem 1: RewriteRule doesn't match leading slash.
Problem 2: Wrong order of Rewrite Rules.
Here is the fixed version:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^test/(.*)/?$ http://test.com/test/index.php?route=$1 [L,QSA,NC]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
I'm trying to override wordpress url rewriting for 1 specific file. My current wordpress install rewrites .html files to the according .php extension. So, for a permalink in MY wordpress installation might look like www.mysite.com/mypage.html.
I have an ACTUAL HTML file i want to show, however the htaccess keeps auto rewriting it by default, here is the code i'm trying to use to IGNORE this specific file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/forex-system-demo\.html$ [NC] #<-- This is the file i want to ignore and run as a NORMAL .HTML file
RewriteRule . /index.php [L]
</IfModule>
I may have had some wierd browser caching going on because what is below now works after clearing cache.
Here is the SOLUTION:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^forex-system-demo.html$ - [L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Here is the SOLUTION:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^forex-system-demo.html$ - [L] # <- this is where I tell wordpress to ignore this url
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>