On root of my server, I have codeigniter with htaccess. I have created a wp/ folder along codeigniter's sub-folders (e.g. application, config) in which I have placed all the wordpress files. Now when someone types
www.abc.com
i redirect him to
www.abc.com/wp/
but I want to hide wp in the url. How can I achieve this without modifying my current file structure? I want wordpress to be my site's front and codeigniter to be my site's backend. The file structure is shown below:
In your root directory, create a .htaccess with following codes. This will map all your http requests to the /wp/ directory.
# ==>Initializaion…
Options -Indexes
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
# ==>Without this line, your /wp/ directory may become visible sometimes
DirectorySlash Off
# ==>Map everything to your /wp/ directory
RewriteRule (.*) /wp/$1 [L]
You also want to hide the /wp/ directoy from URL. For this, create another .htaccess in your /wp/ directory and write following lines:
# ==>Initializaion…
Options +FollowSymLinks
RewriteBase /
# ==>Set default file
DirectoryIndex index.php
#==> If the requested resource is NOT a file, or the URL contains “/wp/” anywhere in it,
# then serve the default file instead
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{THE_REQUEST} /wp/
RewriteRule .* index.php [L]
If someone types “/wp/” anywhere in the address bar, they will not see what is in it. Instead, they will see your homepage.
You may have to adjust the code to suite your requirement.
Related
Actually I am running a Wordpress website with a simple template.
Now for SEO and Speed optimization purposes I would like to make a custom HTML page super simple and well optimized but that is not part of the Wordpress structure.
Basically, my own HTML page.
How can I have my Wordpress thinking the main page is that HTML created page as Main page and the rest of the website managed by the Wordpress ?
My answer requires an Apache or Litespeed server (and possibly others) with mod rewrite enabled, and where AllowOverride has not limited your use of .htaccess file.
See: https://codex.wordpress.org/htaccess#General_Examples
According to the WordPress documentation on that page, if you are using an .htaccess file to handle "pretty permalinks", then it creates and uses the following basic .htaccess file:
# 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 this code does is redirect all requests that are not for an actual file or directory to the index.php file. You can modify this easily and achieve what you want. Simply changing it to something like this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wp_index.php [L]
</IfModule>
# END WordPress
That change would redirect all requests to wp_index.php instead of index.php. So you would make that change, and then rename your index.php file to wp_index.php.
Once that is done, you can create a new index.php file and its contents can be plain HTML. Don't worry about the .php file extension. When somebody goes to your website, if they go to your homepage, the server will serve up the index.php file. For all other requests the server will use wp_index.php and WordPress will handle the request.
Please keep in mind that there are some differences in how .htaccess files work, depending on your server. If my changes don't immediately work, tweaking the .htaccess file contents may be necessary.
There are several questions out there to that topic, but not a single one did match my question, because I am using Slim Framework 3.
One of my routes, for example, is /stats
When I make requests to http://localhost/slim-app/public/stats - it works.
But, I want to make requests to http://localhost/slim-app/stats - and that doesn't work. Slim gives me the error
Page Not Found The page you are looking for could not be found. Check
the address bar to ensure your URL is spelled correctly. If all else
fails, you can visit our home page at the link below.
My folder structure looks like that:
/slim-app
.htaccess
/logs
/public
index.php
.htaccess
/src
routes.php etc
/templates
/tests
/vendor
The .htaccess- File inside the slim-app folder looks like that:
RewriteEngine On
# Some hosts may require you to use the `RewriteBase` directive.
# If you need to use the `RewriteBase` directive, it should be the
# absolute physical path to the directory that contains this htaccess file.
#
#RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
The .htaccess- File inside the public- folder like that:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
</IfModule>
What should I change inside the htaccess- files to make it work? Thank you guys!
When I visit my site I see something like this:
Index of /
wordpress/
This is what file directory looks like:
.htaccess file:
# Do not remove this line or mod_rewrite rules and search engine friendly URLs will stop working
RewriteBase /
# 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
enter code here
What do I need to do so that when I visit example.com and I see the my wordpress site without the Index of / and list of pages?
The problem is that you do not have any index.php file in your public_html. When you get the directory listing, it is because there is not file inside that directory which matches the DirectoryIndex option. A typically WordPress website will include an index.php, so once you place the WordPress files there, that should go away. You could use Options -Indexes in the .htaccess file to hide that page, but that would give you a 403 error, and still not show your contents, so moving the content into the correct location is what you really want to do.
It appears that you may have placed your files into the directory you named "wordpress". If that is the case, try visiting http://example.com/wordpress/. If that is not what you were wanting, then just move the contents of "wordpress" into the public_html/ directory.
I created my first online site. I put all my files on the server (I used Wordpress for now) and it's great, but, when I enter my site address (let's say: www.mysite.com) I see only "Under construction". I only see my website after typing: www.mysite.com/index.php.
How can I make www.mysite.com load index.php without needing to enter it in the address bar?
There is probably an index.html file at the root of your public html folder that you need to delete. Once you delete this, your site will load as normal.
Most web servers load .html files before any other files. So if you have index.html and index.php in the root of your public html folder, it will most likely load index.html first.
You also may need to make sure you have an .htaccess file in the root of your public html folder, and that it contains the basic Wordpress code:
# 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 info on that here.
My Main site displays (mypage.com/site) and all following pages include /site as well
How do I achieve (mypage.com) and no subdirectory displaying?
I have tried Removing the /site in the Site Address URL in Wordpress settings.
But it broke my login and disables me from logging in.
what must I do to remove the /site subdirectory folder dislaying on my website?
What do I do in my htaccess file?
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /site/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /site/index.php [L]
</IfModule>
# END WordPress
I supposed that your WordPress installation is under /site folder. If it's true, you can do it:
If you already has changed the URL, on General panel, to http://mypage.com (without /site), you just need to copy the index.php (under site/) to the root folder.
After copy the index.php file, edit it, adding site/ to the path to wp-blog-header.php:
require( dirname( __FILE__ ) . '/site/wp-blog-header.php' );
The detailed steps of this process are on "Using a pre-existing subdirectory install
" at WordPress docs: http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory
Have you tried to change your document root in Apache?
Something like:
DocumentRoot /path/to/your/site
I don't know if you have access to your hosting, but this would be the best solution as far as I know.
If you can't do it for yourself, you can ask to your hosting provider to do it for you.