codeigniter making duplicating pages with #! include in link of each page - .htaccess

I have an issue on my website which is on CodeIgniter.
All links are making a duplicate copy of each with #! included in URL
for example
https://www.example.com/port-of-portsmouth
link to a page on my website which is duplicated like the below link
https://www.example.com/port-of-portsmouth#!
Both links have the same page content. How to get rid of this error to avoid content duplication

How to get rid of this error to avoid content duplication
You can't
Because # is used as a fragment identifier. For an example, if the URL is https://example.com/#data this means that open the example.com and jump to a specific section of the page with id"data"
See this URL, https://jestjs.io/docs/en/cli.html#cache
When you open the page, it jumps to cache section.
So, basically, your content is not duplicated, it's just opening the same page and then browser tries to navigate to id !, which might not be there and hence nothing special happens.

Related

why does a new page open when the url doesn't match the content loaded

TLDR:
When a page's content is from one site (npr.com), but the url bar was loaded with another address (yahoo.com), why does clicking on a link in the page open a new browser, when if they match (content from npr.com and loaded from npr.com url) they don't?
I had an old habit (10+ years) of typing yahoo.com to get new content to check if my internet is working. Now I would rather use npr.com, but it is quite difficult to change that habit, so I changed the hosts file /etc/hosts (OSX)
216.35.221.76 yahoo.com
216.35.221.76 www.yahoo.com
216.35.221.76 https://www.yahoo.com
so that any time I type yah then Enter with the autocomplete from the browser, it goes to NPR's site, but the URL remains whatever version of yahoo.com that was autocompleted from the browser. Witha quick glance, all the content appears the same (as does the source code), but the url bar has a different URI than npr.com or http://www.npr.com or the like.
But when I click on a link of a Yahoo/NPR link, it opens in a new tab, not changing in the same tab as if it was just an unadulterated NPR page. Why is this?
My best guess is that for this domain, the author has setup a script that automatically adds target="_blank" for links that don't match the current domain name. This is not default behavior.

hiding sub folders from url display

I have my pages categorized as below....
Main index.html is in the root, so this displays when the domain is entered into a browser.
May pages are categorized as below...
/Pages/Automotive/Ford/Mustang/*.html
/Pages/Automotive/Chevy/Camaro/*.html
/Pages/Automotive/Dodge/Charger/*.html
etc...
What I am looking for is a way to hide the subfolders from the url in the browser..
So, if a link, shortcut, or page is at the following:
/Pages/Automotive/Ford/Mustang/Main.html
The following is displayed in the url status bar on the browser...
/Ford/Mustang/Main.html
or even
/Mustang/Main.html
Basically masking the /Pages/Automotive/ Sub Directories.
And, if a this is entered in the browser:
/Ford/Mustang/Main.html
Then, the original page is still displayed at
/Pages/Automotive/Ford/Mustang/Main.html
Is this doable? If so how, I have looked into .htaccess, but I haven't found what I need..
I am also using 1and1 as my hosting company..

Redirect parent not childs htaccess

In my magento module there is an extension.
Some urls like
http://www.domain.com/abc/p#abcs.html
http://www.domain.com/abc/p#xyz.html
etc
But when browsing http://www.domain.com/abc/p -> lead to blank page
I do not need http://www.domain.com/abc/p url
Is anybody help me
I want to redirect the url http://www.domain.com/abc/p to 404 page
without affecting its childs
ie
1. http://www.domain.com/abc/p#abcs.html
2. http://www.domain.com/abc/p#xyz.html
Points to its current position and
http://www.domain.com/abc/p to 404
Any help apperciated
Based on your comment it seems http://www.domain.com/abc/p#abcs.html shows proper content but http://www.domain.com/abc/p shows blank page.
In that case you can't do that via .htaccess because on server side URL will always be: http://www.domain.com/abc/p.
You need to put some custom Javascript in your page and redirect to some non-existant page (resulting in 404) by checking location.href using your Javascript.

htaccess Redirecting or Rewriting to a form results page with variables intact

I am building a website which calls for a page selector on product search results, the page selector currently adds a forward slash and a number (representing the page) to the end of the current URL.
e.g. If I am browsing Washing Machines on "/laundry/Washing-Machines" and I click page 2 on the selector it takes me to "/laundry/Washing-Machines/2" and page 2 loads, this is working fine.
Now, the problem I am having...
I have a form in the sidebar where the user can filter Range Cooker search results by brand, fuel type, size and colour. The form gathers the products from the database that meet the search criteria, and displays the results along side the page selector.
If I leave the form values as default and submit the form I am presented with the results on "/cooking/Range-Cookers/Search?brand=0&type=0&size=0&colour=0" but when I click page 2 on the selector I am taken to "cooking/Range-Cookers/2" which presents me with a 404. If I add "&page=2" to the end of the original URL I am presented with page 2.
Since the page selector is a php include and works fine for every product except the results from my Range Cooker form, I would rather find a solution that leaves the selector php intact.
Is there any way I can add a redirect to .htaccess which would take a link from my page selector e.g. "cooking/Range-Cookers/5" and correctly apply it to the current URL with all form variables intact e.g. "cooking/Range-Cookers/Search?brand=1&type=2&size=0&colour=0&page=5"?
I have experience in HTML, CSS and PHP, but I am new to editing .htaccess and would appreciate any insight into how I can accomplish this. Thanks.
You cannot do this with .htaccess, because the information is not available, when the request hits Apache, or .htaccess for that matter.
When you click the link for page 2, the client requests the URL in the associated href attribute. It doesn't provide any other information available on the current page. If you want this information transmitted, you must modify the link for page 2 from
cooking/Range-Cookers/2
to
cooking/Range-Cookers/Search?brand=1&type=2&size=0&colour=0&page=2
when you deliver the page to the client. Same goes for any other information you need for following pages.

Using a single serverside-scripted page, or multiple unscripted pages?

I often see that websites use more than one page to display their information, while I've always preferred to use a single page which automatically changes its content by means of a PHP script.. Won't it be faster and simpler to have only one page that changes every time using a webpage argument, instead of having multiple copies of the same layout?
For instance:
... <body> ... <?php insert_requested_content(); ?> ... </body> ...
should be simpler than having a bunch of pages with the same header, footer, navbar, etc..
When I create a website, I usually have one index.php page and then the content pages, which are included into the index.php by the script, when they are requested by an argument such as:
http://mywebsite.com/?content=news
So: why people still use many different pages? Is there any particular need of doing this, or it's just a matter of choice?
Do spiders encounter any difficulties when trying to access the content of a website created with this design?
Your program structure is usually made easier by having multiple pages to reflect your different content while maintaining a common header/footer and css that can be inserted as you stated above. Placing all of your content in one page and dynamically trying to determine what the user is requesting and display it properly can become a nightmare of if/else statements if your site gets much more than three or four pages of content.

Resources