.htaccess hide subfolder url in wordpress - php

I've WordPress site with the URL :
http://thelaptopsolutions.in/Laptop%20Solution/
This is working fine but the URL now shows http://thelaptopsolutions.in/Laptop%20Solution/ but I want it to show http://thelaptopsolutions.in
Here's my current htaccess code
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /Laptop%20Solution/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /Laptop%20Solution/index.php [L]
</IfModule>
# END WordPress
Thanks in advance..

I advice you against messing up the contents of the .htaccess file. Revert the changes that you've made to this file and follow the simple procedue.
Login to the admin dashboard.
Go to Settings > General
In the WordPress Address (URL) field type http://www.example.com/site
In the Site Address (URL) field type http://www.example.com
Save the changes and you should be good to go.

Related

Wordpress .Htaccess Usage In Subfolder Site

Could someone help me; where am i doing wrong?
My wordpress site is not in root; i installed it in a directory(newsite/) I mean; there are 2 sites.
My root site(example.com) has default htaccess file.
And this is my sub wordpress site's(example.com/newsite/) .htacces source:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /newsite/
RewriteRule ^newsite/news/hello-world /newsite/news/?title=hello-world [L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /newsite/index.php [L]
</IfModule>
# END WordPress
I just want:
www.example.com/newsite/news/hello-world
(above url should open the url at below; without url change at address bar)
www.example.com/newsite/news/?title=hello-world
Check with different permalink options.
Note : .htaccess file should be writable or paste the suggested code in .htaccess after permalink saved.

wordpress redirecting all pages to homepage

I have a wordpress website www.spiderhost.asia, when i click on any link on the website it's redirecting to the homepage which I don't want, it was working perfectly few days back and I didn't change any config and anything in website , still it's not working properly.
I contacted server admin, wordpress admin regarding same but didn't find any solution for that.
Even I didn't make anychanges to 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
I need help resolving this
That htaccess file is saying that if the file or directory being queried does not exist and it is not index.php, then reroute to index.php. Make sure that the file you're trying to query exists (and that it's in the correct directory).

Rewrite rule in wordpress for wordpress page

I'm running wordpress in my local with "ben.scbw.zec.dev" vhost.
I have created page template to display particular event detail.
http://ben.scbw.zec.dev/event-view?view_event=14
I can access page with above url "event-view" is slug on page and page id = 439 .
Now, I desire to access it with below url.
http://ben.scbw.zec.dev/event-view/this-is-test-event/14/
"this-is-test-event" its fro titel of event any text , i have manage to create URl.
Below is code from my .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
Above is Standard wordpress crated code and i have added following code.
RewriteEngine On
RewriteBase /
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^event-view/([^/]*)/([^/]*)/$ ./index.php?page_id=439&titel=$1&view_event=$2 [L]
here 439 is in page id for "even-view" as i mentioned.
But, I'm not able to access page with "http://ben.scbw.zec.dev/event-view/this-is-test-event/14/" url. it shows me 404 not found error.
I have been trying this for 4-5 day but not able to find solution.
I'm really very Thank full if anyone can help me in this.
First of all, wordpress uses internal RewriteRules to map an url.
So you don't have to add an additional RewriteRule-tag to your htaccess.
You have to register your query parameter and add rewrite rules to the internal wordpress rewrite engine.
#see https://developer.wordpress.org/reference/classes/wp/add_query_var/
#see https://developer.wordpress.org/reference/classes/wp_rewrite/

htaccess redirect wordpress to index2.php

We have a site running on WordPress ada.localhost.com
Now all request to base url (http://ada.localhost.com/) have to go through tracking page (track.com/c/0912321323/?u=xxx) where u parameter is where to redirect user after he is tracked.
I've created a copy of index.php (index2.php) and I want to create htaccess rule to redirect all base url traffic to:
http://track.com/c/0912321323?u=http%3A%2F%2Fada.localhost.com%2Findex2.html (http://ada.localhost.com/index2.php)
Typical WP htaccess file looks like this
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Any clue on how to set it up and if WordPress allow this configuration?
From what I found WordPress won't work with index2.php.
Solution for this is to write a plugin which deals with it.

Wordpress perm links

Whenever I set the permanent links on wordpress to something other than the default
p=123
The links go to 404 pages
For example:
http://thewebsite.com/i/blog/2012/05/sample-post/
Would be linked as the blog post, but it would take you to a 404 result.
What can cause this kind of issue?
You need to have a rewrite in place.
In the root of your website, create a .htaccess file. This will be a hidden file but if you are using Filezilla as a FTP program you will be able to view it.
Put in it 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
Save it in the root of your website, ie, where wp-config goes and it should work.
If you have your website in a sub directory you will need to change the Rewrite base to reflect this instead of / for root.
Hope this helps!

Categories