.htaccess

How to write a htaccess file to wildcard folder to subdomain

半世苍凉 提交于 2020-01-05 07:42:26
问题 I'm trying to redirect all my folders (using a wildcard) to their subdomain. For example: www.mywebsite.com/folder1 to folder1.mywebsite.com/ www.mywebsite.com/folder2 to folder2.mywebsite.com/ www.mywebsite.com/folder3 to folder3.mywebsite.com/ Now without writing a rule for each one of them, is there a way to redirect them all to their respective subdomain? I tried: RewriteEngine On RewriteCond %{HTTP_HOST} !^www\.mywebsite\.com$ RewriteCond %{HTTP_HOST} ^(\w+)\.mywebsite\.com$ RewriteRule

Redirect subfolder to root domain

北城余情 提交于 2020-01-05 07:33:32
问题 I want to redirect the subfolder and allcontents to root domain. For example: http://www.example.com/ubb/ will redirect to http://www.example.com I put the .htaccess on ubb folder and the code is: RewriteEngine On RewriteRule ^.*$ / [R=302,L] However when you access http://www.example.com/ubb/threads.php it will redirect to http://www.example.com/threads.php it should be http://www.example.com Is there any code to try or other possible solution? 回答1: Place this rule in /ubb/.htaccess :

301 Redirect reg expression in htaccess

丶灬走出姿态 提交于 2020-01-05 06:57:59
问题 I'm trying to redirect http://www.domain.com/post/155851321646/post-slug to http://www.kaleandcaramel.com/post-slug (this is actually redirecting old Tumblr URLs to Wordpress URLs) the closest I came was this: RewriteRule ^/?post/([0-9]+).(.*?)$ http://www.domain.com/$2 [L,R=301] but it's not working. 回答1: Use this instead: RewriteRule ^post/[0-9]+/([^/]+)$ http://www.domain.com/$1 [L,R=301] Let me know any problems. 来源: https://stackoverflow.com/questions/42035836/301-redirect-reg-expression

Remove base slug in permalinks of hierarchical custom post type

隐身守侯 提交于 2020-01-05 06:50:14
问题 I have a hierarchical Custom Post Type called project , registered as follows: register_post_type( 'project', array( 'public' => true, 'hierarchical' => true, 'rewrite' => array( 'with_front' => false ) ) ); The URLs currently look like this: https://example.com/project/hello https://example.com/project/hello/world I would like the URLs to look like this: https://example.com/hello https://example.com/hello/world How can I most efficiently accomplish this such that other URLs are not

Failed opening 'pages/' for inclusion (include_path='.;C:\Program Files (x86)\DevDesktop\common\pear') index.php on line 18

限于喜欢 提交于 2020-01-05 06:32:06
问题 When I make the project with .htaccess file, I got an error. The first error is include(D:\learnphp\drupal-7.43\site\pages): failed to open stream: Permission denied in D:\learnphp\site\index.php on line 18 The second one is include(): Failed opening 'pages/' for inclusion (include_path='.;C:\Program Files (x86)\DevDesktop\common\pear') in D:\learnphp\drupal-7.43\site\index.php on line 18 Here is my index.php <?php // Moved functions to their own file so we can use them in page files. include

Failed opening 'pages/' for inclusion (include_path='.;C:\Program Files (x86)\DevDesktop\common\pear') index.php on line 18

十年热恋 提交于 2020-01-05 06:30:12
问题 When I make the project with .htaccess file, I got an error. The first error is include(D:\learnphp\drupal-7.43\site\pages): failed to open stream: Permission denied in D:\learnphp\site\index.php on line 18 The second one is include(): Failed opening 'pages/' for inclusion (include_path='.;C:\Program Files (x86)\DevDesktop\common\pear') in D:\learnphp\drupal-7.43\site\index.php on line 18 Here is my index.php <?php // Moved functions to their own file so we can use them in page files. include

How do I get .htaccess to redirect from wildcard subdomain page to wildcard subdomain folder

荒凉一梦 提交于 2020-01-05 05:47:08
问题 I want to redirect http://*.domain.co.uk/services.php to http://*.domain.co.uk/services where * is a wildcard domain. Ideally, htaccess should read the services page (as I have more than one) and redirect to the same services folder. This is because I have changed my PHP pages to folder/index.php . 回答1: Add this to the htaccess file in your document root(s): RedirectMatch 301 ^/([^/]+)\.php$ /$1/ You'll most likely need that trailing slash because if it's redirecting you to a directory, mod

Conditional “OR” operation in RewriteRule

纵饮孤独 提交于 2020-01-05 05:39:50
问题 I want to redirect certain urls of my old website to the new website. This redirection to new website is conditional i.e if query param contains key "site" with value as "eu", "jp" or "in" then only redirect otherwise do not. RewriteCond %{QUERY_STRING} (?:^|&)site=(eu) [NC,OR] RewriteCond %{QUERY_STRING} (?:^|&)site=(in) [NC,OR] RewriteCond %{QUERY_STRING} (?:^|&)site=(jp) [NC] RewriteRule ^/?fetchHomePage.action$ https://example.com/%1? [R=301,L,NC] RewriteRule ^/?fetchFirstPage.action$

cannot redirect querystring url

一世执手 提交于 2020-01-05 05:35:07
问题 I am trying to clean url redirecting query string URL. I've tried all answer and rules provided in stackoverflow and in other sites, but nothing changed. I thought it was .htaccess file error, but I found it is working fine to generate other error. I am trying to redirect http://localhost/ourallnews/category.php?cat=News To http://localhost/ourallnews/News/ First I tried using this. RewriteEngine on RewriteCond %{QUERY_STRING} ^cat=(\w+) RewriteRule ^ourallnews/category\.php$ /ourallnews/%1?

Removing the PHP file type extension

隐身守侯 提交于 2020-01-05 05:34:19
问题 I'm using this in my top level .htaccess to remove the PHP file type extension on my *.php files. RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.php [NC,L] But I have discovered it also prevents my browser from calling the index.php page in my sub-directories. I need to include /index.php explicitly in the URL. Is there a better way to remove the PHP file type extension on my *.php files? 回答1: here you go: RewriteEngine on RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule !.*\