url-rewriting

regex to replace string with params

北城余情 提交于 2019-12-13 08:52:26
问题 Please help me to create regex for replace a string like: /technic/k-700/?type=repair to a string like /repair/k-700/ Instead of k-700 can be any another combination (between / ) and instead of repair can be only kit . I need pattern and replacement, please. It's so hard for me. My result not working for Wordpress : $pattern = '/technic/([0-9a-zA-Z-]+)/?type=$matches[1]'; $replacement = '/?/([0-9a-z-]+)/'; 回答1: You can try something like this: $test = preg_replace( '~/\w+/([\w-]+)/\?type=(\w+

url rewriting using htaccess for category & product in php

佐手、 提交于 2019-12-13 08:45:01
问题 please help me to complete my project its about ecommerce site in core php as i am a beginner for my site i want seo friendly url for category, subcategory, product and product detail page.... i have pages like this : mysite.com/category.php?category_slug=mobiles : category page mysite.com/subcategory.php?subcategory_slug=samsung : subcategory page mysite.com/product.php?product_slug=galaxy-note : product page and i want to rewrite these url like this : mysite.com/mobiles : category mysite

Yet another mod_rewrite query — Cannot rewrite to pretty url and keep query strings

怎甘沉沦 提交于 2019-12-13 08:28:26
问题 I'm literally at the end of my tether with this. I've researched many other questions and answers on stackoverflow but still can't find the solution i need. I'm starting to think what i want to do is not possible. So... the problem is this. I want to turn the following: e.g. www.mydomain.com/visa-information/country.php?country={COUNTRY-NAME}&passport={PASSPORT-NAME} To the following pretty url: www.mydomain.com/visa-information/{COUNTRY-NAME}-visa-for-{PASSPORT-NAME}-citizens/ I have a

Get the sub url load it into a new url

天大地大妈咪最大 提交于 2019-12-13 08:27:48
问题 Let's say someone comes to my site with this url: mywebsite.com/somethingsomething123 I want to create a new url and turn it into this: anotherwebsite.com/somethingsomething123 How would I be able to do this? Any help would be appreciated. 回答1: So, Using Javascript you it like this : var path_Name; // it will be like somethingsomething123 redirect_Url="www.example.com"; // anotherdomain.com function test(){ path_Name = window.location.pathname; window.location.href='http://'+redirect_Url+path

What is wrong with this .htaccess code?

烂漫一生 提交于 2019-12-13 08:16:33
问题 I need to change article and profile links in my site to dynamic ones. i.e. for article : site.com/article.php?id=12 becomes site.com/article/this_is_title_of_article for profile : site.com/ref.php?user=23 becomes site.com/john_doe So I wrote this to .htaccess : RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^(.*)$ ref.php?user=$1 [QSA,L] RewriteRule ^articles/(.*)$ article.php?user=$1 [QSA,L] So, for

Redirecting http traffic to https in Apache without using mod_rewrite

一笑奈何 提交于 2019-12-13 08:08:33
问题 I am trying a pretty simple thing that I would normally do using a RewriteRule (and which works perfectly when I do). My goal: Force certain (not all) URLs to use the https protocol. Caveats: Apache is behind a crypto-offloader. We would like a single virtual host that deals with both the unencrypted and the decrypted traffic. The offloader forwards all traffic to the same port and sets the X-Forwarded-Proto header. (It also sets the new Forwarded header for future compatibility, but I will

htaccess rewriting to include file in every folder

邮差的信 提交于 2019-12-13 07:48:37
问题 Is there a way I could use htaccess' url rewriting feature to look like there's a file in let's say the /public/some/folder when it's actually in /public . For example I have index.php in root folder and I want it to be like that when I access index.php then it could also behave as its in all the folders and subfolders too When I execute index.php then it will also execute in all folders and subfolders too Update Please understand my question by the example below index.php is in root and I

Redirect rule not working

做~自己de王妃 提交于 2019-12-13 07:44:28
问题 I'm trying to add a forwarding rule for my website. If any of the following URLs are matched: https://www.example.com http://example.com http://www.example.com then it should redirect to to https://example.com I am using URL Rewrite 2 for IIS on Windows 2016. I'm trying to break this into 2 rules as I can't think of how else to do it. The first part of the rule is from http to https <rule name="HTTP to HTTPS redirect" stopProcessing="true"> <match url="(.*)"/> <conditions> <add input="{HTTPS}

Change the URL to URL with HTTPS

*爱你&永不变心* 提交于 2019-12-13 07:43:20
问题 I have my .htacces on my server and it looks like so: RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L] But when I type example.com in my browser it doesn't redirect to https://example.com . How can I do that? 回答1: It would seem it was just the spelling of .htaccess (filename) that was the problem. This has two s , not one, as stated in the question. Bit of an aside... the name of this file (per-directory Apache config filename) can be changed in

Rewrite escaped hashtag # %23

一笑奈何 提交于 2019-12-13 07:40:33
问题 I recently noticed some incoming 404 error hits from URLs with their hashtag escaped. Correct URL structure: http://example.org/#!/thepage or /index.html#!/thepage Escaped/ Incorrect URL: http://example.org/%23!/thepage I tried the following .htaccess rule with little success: RewriteEngine on RewriteRule ^%23!/(.*)$ /index.html#!/$1 [NE] 回答1: Thanks to this answer which pointed me into the right direction: https://webmasters.stackexchange.com/a/76059 Here is the rule that worked for me