How to make a start page in a dynamic directory? - javascript

If I need start page with dynamic language URL like that:
https://stackoverflow.com.ru./
What should I do?
Should I do a redirect from a static start page or other options are exist?
I need the right way.

Use 301 redirect by .htaccess
ru and stackoverflow.com are as examples
RewriteEngine On
RewriteCond %{HTTP_HOST} !^ru\.stackoverflow\.com$ [NC]
RewriteRule ^(.*)$ http://ru\.stackoverflow\.com/$1 [R=301,L]
Place this .htaccess file in stackoverflow.com/ directory.

Related

Locked out of wordpress admin wp-admin while trying to activate https manually [duplicate]

My word press installation resides in public_html/cushbu folder
and it will be accessed by www.example.com/cushbu so i have changed the base url's in wp-config.php
define('WP_HOME','http://www.example.com/cushbu/');
define('WP_SITEURL','http://www.example.com/cushbu/');
Also i've edited this line .htaccess file
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?domain.com/cushbu/ [NC]
the problem is i can't access the wp-admin its redirected to old url
So how can i completely change the base url??
Change the url in your database table called wp_options field's home url and site url. Change it to your new url.
outside of cushbu folder, in public_html folder, you should have .htaccess file modify that file with the following line.
# Redirect Trailing Slashes...
RewriteEngine On
RewriteBase /
RewriteCond $1 !^(cushbu)
and WordPress source has .htaccess file edit like this
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /cushbu/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /cushbu/index.php [L]
</IfModule>
You need to change the site URL and home URL in the database too. Its in the wp_options table. I hope you have database access.
Cheers!
Follow simple steps to replace in core database url
1) You need to export your old database to local computer
2) Notepad++ editor or some other editor tool. replace (cntrl+H) in notepad++
3) First Find http://www.example.com/cushbu/ and Replace with new URL eg. http://www.newexample.com/cushbu/
4) Second Find without http www.example.com/cushbu/ and Replace with new URL eg. www.newexample.com/cushbu/
5) Final find any old url is present or not.if yes than replace by new url and save.
6) Import new replaced database to old database and login by wp-admin and click on Settings / Permalinks now it's done.

HTML add path to sub pages

How do I add paths without .html on my webpages?
My main site: www.example.com
About Page: www.example.com/about
Another Page: www.example.com/test/contact
Create a file with the name .htaccess in your root directory
and add this code to it :
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html [NC,L]
but you need to use http server
There can be two ways to go about this:
(a) URL rewriting: In the .htaccess file in your root folder (if there isn't one already existing, create it) make the following changes:
RewriteEngine On # Turn on the rewriting engine
RewriteCond %{REQUEST_FILENAME} !-d # Check that the URL doesn't point to a directory
RewriteCond %{REQUEST_FILENAME}.html -f # Check that the URL points to a file with the extension html
RewriteRule ^(.*)$ $1.html [NC, L] # Finally, make the change with a regex and flags like NC which ensures that this rule should be case-insensitive, and 'L' stops processing any more rules if this one is used.
Here is a good resource for URL rewriting: https://aloneonahill.com/blog/url-rewriting-for-beginners/
(b) Create an index.html file in each of your folders: This way the URL ends at the directory name and doesn't show the index.html leading to cleaner URLs (for e.g. example.com/about instead of example.com/index.html).
I am not sure about the issues with the second method. It does look clunky.

remove the index.php WAMP

I have a site and it works to type "www.mysite.com/folder/" (if i have a index file in that folder).
It also works to type "www.mysite.com/folder/index.php"
All fine and good, but I want it so if you type /index.php it will remove the index.php on the end also if I use a form and post to index.php I don't want that to show in the url.
I have looked around and seen every solution say .htaccess rewrite, but It don't seem to be working / or its just not the same thing that I want?
or do I need to use javascript and update the address bar?
(I'm using WAMP)
EDIT:
Things I've have tried:
1
httpd.conf
AllowOverride All
2
I have enabled:
Apache modules> rewrite_module
3
I have created a .htaccess placed in my wamp/www folder
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
4
wamp/apps/phpmyadmin/config.inc.php
added
$cfg['index_page'] = '';
EDIT 2:
This look like it works, but it messes up my POST to index.php so it breaks my login (It don't start the session).
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)index\.php($|\ |\?)
RewriteRule ^ /%1 [R=301,L]
An .htaccess file is definitely the correct solution. If it isn't working, try one of these possible answer:
.htaccess not working on localhost with XAMPP
How to use .htaccess in WAMP Server?
.htaccess not working on WAMP
Update: Re-reading your question, you might be using an older htaccess script (for PHP < 5.2.6 version). I'm not sure if the script will work in current versions. Try:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
The ? after index.php in final line is the difference
If above doesn't help, what version of PHP does the PHP command phpinfo() report?
<?php
phpinfo();
die();

Link not opening properly after hiding file extension using htaccess

I have used ht-access to hide .php file extension. Inside .htaccess file my code is :
# Apache Rewrite Rules
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
# Add trailing slash to url
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/|#(.*))$
RewriteRule ^(.*)$ $1/ [R=301,L]
# Remove .php-extension from url
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^([^\.]+)/$ $1.php
# End of Apache Rewrite Rules
</IfModule>
It's hiding .php file extension well. But problem is that, link inside href attribute is not opening properly.
I have two files:
public_html/afiliate/product_details.php
public_html/afiliate/afiliate_login.php
Inside product_details.php I have given link of afiliate_login.php like this
Log in
Clicking Log in I should go to a page like
example.com/afiliate/afiliate_login/
But it takes me to
example.com/afiliate/product_details/afiliate_login/
And hence a 404 error
Again notice that, if i manually type this URL
example.com/afiliate/afiliate_login/
that's OK, it goes to the page as expected.
Now how I can make links work properly?
After this code:
RewriteRule ^([^\.]+)/$ $1.php
put the below code
RewriteRule afiliate_login$ afiliate_login.php [L]
basically means that any request that comes to afiliate_login will show the data from afiliate_login.php
You got that problem because in your anchor tag you are using relative url. Since your url look like this without the file extension like, example.com/afiliate/afiliate_login/ , affiliate_login/ will be also considered as a directory and the html thinks that the anchor tag is in affiliate_login/ but it in reality it does not exists there so you get 404 error.
Previously the browser considered product_details.php as a file. but now its a folder, because its product_details/
one option available here is to update the link's like this
Log in
but its always suggested like the link below
Log in

Redirect all file in folder to another page, but still allow html file access

I have directory like
index.html
datafolder (all my js and css file in here)
I want every direct access to file in datafolder like: www.sample.com/data/main.js will redirect to some error page (404,403, anything) or redirect to www.sample.com
But index.html still can access these files.
(please answer if you have any solution)
Thank you so much.
Put this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$
# change this to your actual domain name
RewriteCond %{HTTP_REFERER} !^http://(www\.)?domain\.com/ [NC]
RewriteRule ^datafolder(/|$) - [F,NC]

Categories