admin管理员组

文章数量:1123849

Does anyone know how I can get rid of index.php in my URL? Right now if I add a new page, the address will be:

www.mywebsite/index.php/page1

But I want it to be:

wwww.mywebsite/page1

I surfed the web a lot! Changing the permalink doesn't work. Does anyone know how I can fix this?

Does anyone know how I can get rid of index.php in my URL? Right now if I add a new page, the address will be:

www.mywebsite.com/index.php/page1

But I want it to be:

wwww.mywebsite.com/page1

I surfed the web a lot! Changing the permalink doesn't work. Does anyone know how I can fix this?

Share Improve this question edited Mar 25, 2017 at 9:32 geek2000 asked Mar 23, 2017 at 9:30 geek2000geek2000 1132 silver badges7 bronze badges
Add a comment  | 

4 Answers 4

Reset to default 4

This is a classical case. All you need to do is to use Rewrite Rules. With Apache, you can do it in .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

More on this in codex.

first try to change the permalinks in general setting of you website dashboard.....if not then you have to edit your .htaccess file....hope this will help to resolve the issue..!!

I was also a victim of this error.But Now have solved the issue in CWP permalink index.php remove solution as follow:

Create a .htacess file in the root directory of your website /public_html/yoursite.com

Write the following code in it

# 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

then Goto wp-admin >>> settings >>> permalinks

Select "Custom Structure" and remove "index.php" only from it

Save and check ... It works perfectly!

thanks at all

I will extend the correct answer.

If you're using Apache webserver

1. First check on the Wordpress admin panel in Setting/Permalinks if you selected the desired way to show links.

2. Check if the file .htaccess on the DocumentRoot folder of your virtualhost has this code:

    # BEGIN WordPress
    <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>
    
    # END WordPress

3. Check if in the Apache VirtualHost config you have correctly setup the AllowOverride option It will work with AllowOverride All or AllowOverride FileInfo All

3. Check if the mod_rewrite module it's enabled in your Apache config

4. ¿Using FPM/FastCgi/Cgi PHP interpreter?

If you're using the PHP module of Apache you should be ok. But if you're using FPM/FastCgi/Cgi you should do this because Wordpress tries to detect if the mod_rewrite module it's enabled on Apache. But if you're not using the apache module that function wordpress uses returns nothing and it will think you don't have the mod_rewrite enabled.

So you should need to fake one function inside the functions.php of your theme. I suggest you to use a child-theme of your theme to avoid problems when updating.

You should add this code to the functions.php of your theme usually (wp-content/themes/<your_theme>/functions.php

add_filter('got_url_rewrite', 'enable_url_rewrite');
function enable_url_rewrite($got_url_rewrite) {
            return true;
}

If you're using Nginx

Check if you have a similar code inside the virtualhost. If not add it.

# if requested file doesn't exists, send to bootstrap
if (!-e $request_filename)
{
    rewrite ^(.+)$ /index.php?q=$1 last;
}

With nginx it will finish here, but if you continue to get problems check the last item of the Apache section.

本文标签: permalinksHow to get rid of indexphp