I'm using wordpress for a site,
this url before tes.com/index.php/about/
i want url like this tes.com/about/
I have tried copying parts of WordPress' .htaccess, however shows a 404 error.
My .htaccess file looks like:
# 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
Any ideas on where to start and how to accomplish what I'm looking for?
Go to your WP-ADMIN-->Settings-->Permalink and use the permalink structure change there, if it generate any .htaccess file copy the content and update your .htaccess file.
Or Check if your hosting mod_rewrite is enable by creating a file phpinfo.php with content,
Upload this file and browse via Browser. So you know which modules are enabled. You need mod_rewrite enable to remove index.php from URL.
Try this -
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /test.com/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /test.com/index.php [L]
</IfModule>
The official instructions will give you clean urls. So best to follow this
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Related
I have the following code in my htaccess file which is related to 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]
</IfModule>
I created a new folder called test and when I try to access it from the browser, it shows a 404 error.
when I remove the code above from the htaccess file, I can access the new folder but the rest of the wordpress site breaks up. so I can't get rid of this code at all.
I tried adding this to the code:
RewriteCond %{REQUEST_URI} !^/test
so it looks like this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/test
RewriteRule . /index.php [L]
</IfModule>
With no result and I still see the 404 error.
Could someone please advice on this issue?
I've tried many ways including this and still nothing works!!
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_URI} !(test) [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
How to move WordPress installation to sub folder
Move wp-*, index.php, .htaccess to your new wordpress folder
Edit wordpress/.htaccess:
Find this line: RewriteRule . /index.php [L]
Make it: RewriteRule . /wordpress/index.php [L]
Create a new file in /path/to/www called .htaccess then add this:
RewriteEngine on
RewriteRule ^$ https://www.example.com/ [L]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^/wordpress/index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /wordpress/$1 [L]
</IfModule>
Another way to do move all thing in sub directory
rename htaccess to backhtaccess.
Login to admin
Go settings -> permalinks-> save changes. All done.
=========================UPDATED ANSWER==============================
Add this line in your themes functions.php:
include(ABSPATH . 'custom.php');
Explanation:
Your wp-config.php should contain the following code (near the bottom of the page):
/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
They are saving the path to the wordpress installation to ABSPATH.
It will be something like "/var/www/foo/" or similar. So you can concat the ABSPATH with path to your file. If for example, your php file is located inside some folder like this "example.com/somefolder/custom.php" you would use
include(ABSPATH . 'somefolder/custom.php');
Hope this helps!
=======================Answer 3======================
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/(test/.*)$
</IfModule>
You can whitelist a folde using
RewriteCond %{REQUEST_URI} !^/(test|test/.*)$
Reference link :
.htaccess & Wordpress: Exclude folder from RewriteRule
I'm trying to load the content(index.html) from specific folder on specific(already used URL) in Wordpress.
Here's the .htaccess file(default):
# 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
I've tried with few variations of this rewrite rule:
RewriteRule ^/category/funny-posts/ /funny-images/ [L]
So funny-images is a directory on my server where I have WP installed. Both of them are in the root folder.
How can I load index.html from /funny-images/ when I type www.site.com/category/funny-posts/ ?
If the index.html file is not displaying (and the URI you want is being passed to WP) it's probably because you're putting the rule at the end. Try putting it just after RewriteEngine On. Oh, and I don't think you'll need that RewriteBase. Also, you don't need that leading slash in the new rule, just before category.
Your file should now look like this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^category/funny-posts/ /funny-images/ [L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
I have Wordpress installed on a shared host at Site5. It's installed in the root directory:
www.domain.com
I have another directory that I want to be able to access outside of the Wordpress site:
www.domain.com/directory/
When I visit this URL, I get Wordpress's 404-page. The .htaccess file, as modified by WP, reads:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
I assume I need an edit to the .htaccess file to access this directory?
Edit .htaccess present inside "directory"
It should be:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /directory/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /directory/index.php [L]
</IfModule>
I am converting my old site on wordpress and I don't want to loose any of the indexed "juice" as the old site has been going for 2years or so.So i have to make the same url.In my wordpress site i want to add .html at the and of my URL. I am using a plugin thats adding .html to all pages.
but its not adding .html on my product page.I want to add .html to all of my urls.
It has been suggested to us to use .htaccess rules to solve the problem, but we do not know where to start.
here is my wordpress site url.
http://www.fearfashion.com/
My full htaccess looks like this:
# 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
Any help would be appreciated.
You can try a rule like this to force redirect non .html URLs to .html:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !\.html$ [NC]
RewriteRule ^(.+?)/?$ $1.html [L,R=301]
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>