简体   繁体   中英

Redirection from the php file

I'm looking for a little help from someone who knows PHP, in short, it looks like this: I once made a website for a customer with products on the Jomla CMS system, and the product was located, for example, at:

www.mysite.pl/index.php/productall/product1

www.mysite.pl/index.php/productall/product2 etc..

currently his site has been changed and is in the classic html5 / css / js without any CMS, but in the same old directory and the product is on: www.mysite.pl/product1.html

The client created QR codes for himself, but to the old page and printed on each product and now I would like to create an index.php file, which will redirect the traffic depending on the call in the browser, because now as the QR code is being scanned it jumped out because there is no such adreas as before.

For now, I created an index.php file that redirects to

www.mysite.pl/allproduct.hml

where is the list of all products but I would prefer it to be as before that is, each QRcode was redirected to the chosen product. Can you do it somehow? PLEASE HELP

now i have this code in index.php

Instead of messing with PHP, You could try adding redirect commands within the htaccess file? ( if you can still use one? ) The " .htaccess " file should be located in the site root. ie: /public_html/.htaccess

within this file you can create redirects from the old address to the new one.

Redirect 301 /oldProductLink1.html http://www.example.com/NewProductPage1.html
Redirect 301 /oldProductLink2.html http://www.example.com/NewProductPage2.html

:)

There's no easy solution you must create a .htacess file and place on your root folder then redirect all the old urls to new url for each product

Redirect 301  /index.php/productall/product1 www.mysite.pl/product1.html
Redirect 301 /index.php/productall/product1 www.mysite.pl/product2.html
Redirect 301 /index.php/productall/product1 www.mysite.pl/product3.html
Redirect 301 /index.php/productall/product1 www.mysite.pl/product4.html

If the question is only about PHP and there is no way to use web server URL rewriting or redirect, then you should create files like :

/index.php/productall/product1 /index.php/productall/product2

Where index.php would be a directory. Each file should contain something like :

header('location: /product1.html'); exit();

Where the product number should be set according to file name.

i still have this:

The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

I removed this my test index.php file and created .htaccess in the root directory with yours codes

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM